0

How to know the indentation of certain codes in python

28th Apr 2020, 11:55 AM
Corporate Monster
Corporate Monster - avatar
2 Réponses
0
Indentation normally occurs after a colon in python and after an opening curly braces in Java. Have a look at these files and where they are indented. https://code.sololearn.com/cERTjCwl2BYH/?ref=app https://code.sololearn.com/chdwD1G0UKyQ/?ref=app
28th Apr 2020, 12:01 PM
rafalzacher1
0
You have to think of indenting as the flow of control. I think of each indented line as part of the next less indented line above. You have to tell the computer EXACTLY what you want it to do and sometimes that can be very specific. To do that, indentation is used. for i in range(10): if i % 2 == 0: #if i is even if i < 7: #ALSO if i less than7 print('low number') else: #if the first check #above says the number is odd print(i)
28th Apr 2020, 12:09 PM
Slick
Slick - avatar