dimanche 5 avril 2015

Python - How to add a random number to list?

Hello awesome coding folks!


Does anyone have a good idea to add a random number to a list? I am trying to get a list to log the random numbers that are generated inside a loop. Here is an example of the code inside the loop:



stuff = {'name': 'Jack', 'age': 30, 'height': '6 foot 9 inches'}

tester = [0]

print(tester)

tester.append[random.randint(1, len(stuff))]

print(tester)


Apparently the output of random.randint is not subscriptable, but I'm not sure how else to write this.


Thank you in advance for the help!





Aucun commentaire:

Enregistrer un commentaire