0
Please i am facing an indentation error here
I think it is not nesting the elif condition, what should I do? https://code.sololearn.com/c70zjiYh9pZT/?ref=app
5 Antworten
+ 3
Hi! It looks like you may have mixed up Python 3 and Python 2 syntax. Only Python 3 uses print with parentheses, and only Python 2 uses raw_input(). I've made them all for Python 3, and also tried to fix your indentation issues.
import random
n = random.randint(1, 100)
User = int(input("Enter the number here"))
while User != n:
print()
if User < n:
print("The number guessed is low")
User = int(input("Enter the number here"))
elif User > n:
print("Sorry, but the number you guessed is too high")
User = int(input("Enter the number here"))
print("Good Job, you've guessed the number correctly")
Also, please note that on Sololearn, since we have to enter all the inputs at the same time, this code will not work so well here. But I believe it should be fine in your PC. Please let me know otherwise!
Thanks, and happy coding! :)
+ 2
Py think that line 9 your code is terminating the if, because it has less identation than the if
That's why the error at line 11, bacause you elif cant see the if because its already closed
+ 1
Fix identation at line 9, 14, and 19 it'll do
+ 1
Just add tab in those lines, nothing complicated
0
can you re write the code