+ 2

about "print" in python

why when I insert any if/else operation in python, and I insert a print operation next, there is an error, that says: "expected an idented block" or something like?

24th Jul 2018, 8:48 PM
Jean
Jean - avatar
5 Antworten
+ 3
Because proper indentation is crucial in Python syntax. You have to indent expressions within the if statement.
24th Jul 2018, 8:51 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
jesus! how i don't see it. really thank u, sorry about that...
24th Jul 2018, 9:02 PM
Jean
Jean - avatar
+ 1
Check it out: https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2277 You should maintain the proper indentation throughout the whole code. Within the if statement, you add four (or any other number, but it has to be consistent on the whole block) spaces before the instruction, like this example below: if x=1: print(x) else: print(x*2)
24th Jul 2018, 8:54 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
how I do that?
24th Jul 2018, 8:52 PM
Jean
Jean - avatar
0
simply hit tab 🙂
30th Jul 2018, 1:50 PM
Lucky Shrestha