+ 3

Why intendation is important when coading if and else?

x=10 if x>11: print('True') else : print('False')

15th May 2021, 4:24 AM
Cai
Cai - avatar
1 Antwort
+ 11
indentation is python is very important it's not only for code readability but to also indicate a block of code. once a python interpreter sees this if x>11: the interpret would know that any statements with indentation of 1 tab are its block and would execute accordingly until it sees a change in indentation like else:.
15th May 2021, 4:32 AM
RKK
RKK - avatar