26th Sep 2019, 10:11 AM
Payal
3 Answers
+ 2
Colon tells that the following code belongs to a statement. In: if condition: statement1 statement2 statement1 would only be run, when: 1: program reaches the "if condition:" line. and: 2: condition evaluates to True. statement2 don't have anything to do with the if statement.
26th Sep 2019, 10:39 AM
Seb TheS
Seb TheS - avatar
+ 2
The colon separates the condition from the body, the body of the if statement does not necessarily have to start indented on a new line. For example: if condition: doStuff(); moreStuff();
26th Sep 2019, 10:50 AM
jtrh
jtrh - avatar
+ 1
It is the Python syntax, it allows for better readability.
26th Sep 2019, 10:19 AM
Glenn 🙏
Glenn 🙏 - avatar