I have the following code:
There exists a numpy array multidimensional_array
which has either has all integers and no zeros, or one zero among many integers:
zeros_list = []
for line in multidimensional_array: # if find any zeros, append to list 'zeros'
for x in line:
if x.any() == 0:
zeros_list.append(x)
else:
pass
for item in zeros:
if item == 0:
sys.stdout.write( 'True') # if there is a zero, True
else:
sys.stdout.write( 'False') # otherwise, False
Unfortunately, this doesn't run correctly. If there's a zero, it outputs True
. If not, nothing happens. Each time I run this within a python script script.py
, it should reset. How can I set this to run 'False'?