The while loop is not working properly. The again variable will dictate whether or not the while loop will be executed again. If again = 1, then the while loop will be executed and the program will run again. If again =0, then it will not.
For some reason, again=1 always, so no matter what, while loop is always being executed. Does anyone notice an error in the code?
score = 0
loops = 0
again = 1
while (again != 0):
import random
real = random.randint(1,9)
fake1 = random.randint(1,9)
fake2 = random.randint(1,9)
comb = random.randint(1,9)
rep = 0
guess = 0
if (comb == 1 or comb == 2 or comb == 3):
print(real, fake1, fake2)
loops += 1
guess = int(input("Choose between these numbers"))
if (guess == real):
score += 1
print ("Congrats!")
else:
print ("Wrong, better luck next time!")
if (comb == 4 or comb == 5 or comb == 6):
print (fake1, fake2, real)
loops += 1
guess = int(input("Choose between these numbers"))
if (guess == real):
score += 1
print ("Congrats!")
else:
print ("Wrong, better luck next time!")
if (comb == 7 or comb == 8 or comb == 9):
print (fake2, real, fake1)
loops += 1
guess = int(input("Choose between these numbers"))
if (guess == real):
score += 1
print ("Congrats!")
else:
print ("Wrong, better luck next time!")
again == int(input("Do you wanna go again?"))
print(again)
again ==isn't assignment, it's checking for equality.