Andrew98
Andrew98

Reputation: 41

Create a zero vector of size n in Python

I would like to create a function of n. I would like the function to return a zero column vector of size n.

To clarify if I choose n=3, in return I get:

np.array[[0], [0], [0]]

Upvotes: 1

Views: 5877

Answers (2)

user2952903
user2952903

Reputation: 385

def f(n):
    return np.array(n*[[0]])

is that the function that you need?

Upvotes: 0

Travis Black
Travis Black

Reputation: 715

def colvector(n):
    return np.zeros((n,1))

Upvotes: 1

Related Questions