+ 2

Is semicolon after a statement compulsory in python?

will compiler give any error if we write print("Hello World") and print("Hello World");

26th Mar 2018, 6:40 PM
Dhananjay Panage
Dhananjay Panage - avatar
5 Réponses
+ 11
you can try and see 😊
26th Mar 2018, 7:04 PM
Vukan
Vukan - avatar
+ 4
I hardly ever use semicolons in python. This works, if both statements are on the same line: print("bla"); print ("bla bla")
26th Mar 2018, 6:44 PM
Paul
Paul - avatar
+ 4
If you put semicolon after a statement in python YOU WILL NOT HAVE AN ERROR. It is used normally if you want to put two statements in the same line, like: print('Hello'); print('World') But that is not considered pythonic and it is rarelly used. If you use it like this: print('Hello'); print('World'); you will not get an error. But the semicollon is not necessary. EDITED: here is the code to prove: https://code.sololearn.com/c304zpwZeN12/?ref=app
26th Mar 2018, 7:15 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 2
if you write semicolon in python compiler will give error
26th Mar 2018, 6:43 PM
Raj Chhatrala
Raj Chhatrala - avatar
- 1
No, I'm pretty sure you get interpreter errors if you put any semicolons after statements
26th Mar 2018, 6:51 PM
TurtleShell
TurtleShell - avatar