mercredi 2 août 2017

Python3 - random list choice: How do I make sure the same item isn't ever repeated twice in a row, one after the other?

import random

welcomes = ["Hello","Hi","What's up","YO", "Piss off"]

chosen = random.choice(welcomes)

print("You have entered the welcome cave ----- {} -----".format(chosen))

How do I make sure that Hello for example isn't repeated twice in a row? It's fine if they're repeated again later, just not straight after.




Aucun commentaire:

Enregistrer un commentaire