+ 4

So we don't use semicolons in python. How python understands that one statement ends ?

5th Dec 2017, 2:52 AM
Bijay Sharma
Bijay Sharma - avatar
5 Réponses
+ 14
Python is an interpreted language, it is made so as to carry out each line at a time(interpreted as you type)and not fully compile and run as languages like C++ do. That said, Every line in python code acts as a new line/statement thus when you write print("Hello") print("World!!") these two will be printed on different lines as they are written on different lines...
5th Dec 2017, 3:09 AM
Frost
Frost - avatar
+ 10
Oh thanks @Eric, didn't knew about the default keyword argument... 🤔😉
5th Dec 2017, 4:31 AM
Frost
Frost - avatar
+ 6
Also, Python allows you to put two statements on one line if you separate them with a semicolon. E.g arr = [] ; count = 0 is permissible, if bad style. One minor quibble about Frost's otherwise good answer. The output of two print statements occur on separate lines because of the default keyword argument end='\n' . If you define end=' ', then the two print statements will print on the same line.
5th Dec 2017, 4:22 AM
Eric Blinkidu
Eric Blinkidu - avatar
+ 2
Python interpret each new line as a separate line of code Thanks to its complex structure, which makes one easier to code in python
5th Dec 2017, 6:00 AM
#RahulVerma
#RahulVerma - avatar
5th Dec 2017, 6:03 AM
#RahulVerma
#RahulVerma - avatar