spam = 1
lam = ""
while spam < 5 and lam != 2:
print("What is 1 + 1")
lam = input()
spam = spam + 1
if spam < 5:
print("You got it right")
else:
print("You got it wrong")
After I put 2 as my input lam = 2 making the condition false. However it still runs 4 more times due to the spam instead of ending.