'Which usage is correct when re-initialising a numpy array?

I need to re-initialise an array to zero inside my program. What is better style/ correct: reuse a np.zeros statement or set the array items to zero using a for statement?

Method A

    a=np.zeros((m,n))
    ...
    for ne in range(nel):
        ...
        a=np.zeros((m,n))

Method B

    a=np.zeros((m,n))
    ...
    for ne in range(nel):
        ...
        for i in range(m):
            for j in range(n):
                a[i,j]=0.


Solution 1:[1]

It simpler and more readable to use again

a = np.zeros((m,n)) 

but the simplest is to assign all values at once

a[:] = 0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 furas