python - Create a loop to change ints in a list to another int? -
how take list of numbers
numlist = [] while len(numlist) <= 1000: numlist.append(1) while len(numlist) <= 1000: numlist.append(0) print(numlist)
now how go changing 0?
a loop?
you're not changing first set of elements add. see comment added code:
numlist = [] while len(numlist) <= 1000: numlist.append(1) # numlist thousand elements long, while loop # body never executed. while len(numlist) <= 1000: numlist.append(0)
try instead:
numlist = [] while len(numlist) <= 1000: numlist.append(1) in range(0, 1000): numlist[i] = 0 print(numlist)
Comments
Post a Comment