dimanche 8 octobre 2017

How do I randomly select an item from a list in Jython using a while loop?

I need to make something that randomly picks something from a list randomly, but the catch is that it has to be with a while loop. I honestly am not sure where to start. I was thinking something with a counter? Maybe I am completely wrong. I am not good at this.

x = ["Bob", "Jim", "Billy", "OtherRandomName"]
counter = 0
while counter < x:
x = x + randrange(1, 5)
x = x + 1

I was thinking something like that, but I am probably way off. Any help would be appreciated. Thanks!




Aucun commentaire:

Enregistrer un commentaire