lundi 24 août 2020

Python Random - change random value from list each time I use print

I know this is probably one of the easiest things in the world to do, and I'll feel like an idiot once someone answers, but please, help.

import random

stuff_list = ['a1', 'a2', 'a3']
stuff_item = random.choice(stuff_list)

print(stuff_item)
print(stuff_item)
print(stuff_item)

This makes it choose a random value (Ax) from stuff_list, but each time I print stuff_item I always get the same value from the list. How do I make it so that each time I use print, it randomises it again?




Aucun commentaire:

Enregistrer un commentaire