This is the only method I know of making a list of the same size with zeros. Just curious, is there another way?
line = [13,20,0,44]
result = []
for i in range(len(line)):
result.append(0)
print (result)
This is the only method I know of making a list of the same size with zeros. Just curious, is there another way?
line = [13,20,0,44]
result = []
for i in range(len(line)):
result.append(0)
print (result)
Python 2 & 3
out = [0 for _ in line]
-- OR --
out = [0] * len(line)