mercredi 12 mai 2021

Python Randomly Choose from the list but will always choose it until it isn't available [closed]

First of all, my apology but I don't have a code to show nor have any idea on how to start.

I was thinking of using random but couldn't find any shared information in particular.

Anyway, for example:

fruits = ['apple','orange','banana','lemon','grapes']

What I want to achieve is whenever persons let's say will choose and eat i.e. first run, person1 will randomly choose and eat, let's say he choose and eats apple, every time the script run, person1 will always choose and eats the apple until apple will not be available and will just choose other fruit randomly.

So if it's multiple person, eat person will randomly choose from the fruits and will always choose and the fruit they had chosen at first until that fruit isn't available.

So if person1 already randomly chosen apple, then person2,3,4,5 will have to choose other fruits coz it's already taken.




Aucun commentaire:

Enregistrer un commentaire