+ 1

Expected an indential block error when trying to use if statement on python..why is this?

4th Jul 2019, 3:46 PM
Ayo Ashaolu
Ayo Ashaolu - avatar
6 Antworten
+ 5
You probably didn’t space it correctly. Python is very specific about spacing. Could you share the code so we can help you fix it?
4th Jul 2019, 3:49 PM
Jax
Jax - avatar
+ 3
Probably because you didn't use indentation. Did you use this: if (True): print("true") instead of: if (True): print("true") ?
4th Jul 2019, 3:50 PM
Airree
Airree - avatar
+ 1
x=int(input('First number')) if x>4: print(' x greater than 4 ') This is an example..yets it gives expected an indented block error
4th Jul 2019, 4:22 PM
Ayo Ashaolu
Ayo Ashaolu - avatar
+ 1
The problem is that you didn't indent the part after the if statement
4th Jul 2019, 4:23 PM
Airree
Airree - avatar
+ 1
Correct it let me see pls
4th Jul 2019, 4:29 PM
Ayo Ashaolu
Ayo Ashaolu - avatar
+ 1
x = int(input("First number: ")) if x > 4: print("x is greater than 4")
4th Jul 2019, 4:30 PM
Airree
Airree - avatar