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
  • 676
  • 1
  • 8
  • 22

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
  • 114,268
  • 16
  • 167
  • 218