random number

so im trying to get the code to run until the user guesses the right number, but for some reason, even if the user guesses the right answer, it still says "sorry that was wrong" (or whatever i put in the code) any ideas why it isnt printing the "congradulations" ?

You are viewing a single comment. View All

simply x need to be the first line
import random

x = random.randint(0, 10)
while 1:
print("guess a number from 1 to 10, then i will say a random number, and we will see if you get it right,")
n = int(input("guess a number from one to ten:"))
if n == x:
print("Congradulations, thats correct")
print("so you were wrong, good luck next time")