Getting a syntax error in Python when attempting to use an if/else statement -
import random x = (random.randrange(0,100)) print("i (the computer) have thought of number between 0 , 100.") print(x) guess = int(input("take guess: ")) while guess != x: if guess > x: print("your guess high!") elif guess < x: print("your guess low!") else guess == x: print("you've guessed number!")
when seek run code, syntax error , highlights word "guess". thought what's wrong here?
edit: may doing while loop incorrectly, if remove while loop, still same error don't think that's issue.
the else
mustn't have condition.
it's executed when if
/else
blocks fail , hence doesn't require one.
python syntax
No comments:
Post a Comment