Hi I am trying to make a computer vs. computer guessing game and I don't want the computer1 to guess the same number twice. I want to know how to stop this. I believe it is around the if statement, but I'm stuck. I need help.
from random import randint
try:
guess = randint(0,5)
computer1 = randint(0,5)
GuessList = [ ]
GuessList.append(computer1)
while computer1 != guess:
print("COmputer guessed ",computer1)
if computer1 in GuessList:
computer1 = randint(0, 5)
#computer1 = randint(0,5)
except KeyboardInterrupt:
print("goodbye")
print("COMPUTER FINALLY GUESSED "), guess)
My output is the computer1 guessing the same number more than once, but it will eventually get it.