+ 2

while loop

Would it be correct to say that (in the programming language Python), when a condition is introduced ( while and if for example), further lines of code will be indented by at least 4 spaces?

22nd Mar 2018, 4:27 PM
arbaaz
4 odpowiedzi
+ 5
All Python cares about is indented so: if True: print("works") else: print("oops") one space or 20 is all good, just be consistent so that your code doesn't confuse the reader.
22nd Mar 2018, 6:41 PM
John Wells
John Wells - avatar
+ 3
Thank you all for your answers.
25th Mar 2018, 8:58 PM
arbaaz
+ 2
https://code.sololearn.com/cqIOz90T6ciK/#py while True: print("Yup. Its 4 spaces.") break ::: OUTPUT :::: Yup. Its 4 spaces.
22nd Mar 2018, 4:45 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
Use tab, don't be the kind who presses space four times
22nd Mar 2018, 5:14 PM
Tomer Sim
Tomer Sim - avatar