0

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)
german
  • 55
  • 1
  • 1
  • 7

1 Answers1

3

Python 2 & 3

out = [0 for _ in line]
-- OR --
out = [0] * len(line)
Daniel Trugman
  • 8,186
  • 20
  • 41