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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -