[Solved] how to check if the number is in the list [duplicate]


You can just add,

while computer1 in GuessList:
    computer1 = randint(0, 5)

After your computer1 = randint(0, 5). You might have to remove your GuessList = [ ] because that will reset your GuessList each time. Instead, you should have that at the very start of your code and leave the append statement.

Or you can use

computer1 = random.choice(GuessesLeft)

GuessesLeft is a list of all the numbers computer1 has not guessed. Each time it makes a guess youc an just delete that item from the list.

solved how to check if the number is in the list [duplicate]