1

In c/c++ we use to declare three-dimensional using the following syntax.

`long long dp[20][180][2]; `
 memset(dp, -1, sizeof(dp)); 

My code:

import numpy as np
x = np.zeros((20,180,2))

How can we declare and initialize a three-dimensional array in python?

DRV
  • 510
  • 6
  • 17

1 Answers1

1

If you want all the values initialized to -1 like in your memset example, then you'd want np.full instead of np.zeros

import numpy as np
x = np.full((20,180,2), -1)
Cory Kramer
  • 107,498
  • 14
  • 145
  • 201