+ 2
Is semicolon after a statement compulsory in python?
will compiler give any error if we write print("Hello World") and print("Hello World");
5 ответов
+ 11
you can try and see 😊
+ 4
I hardly ever use semicolons in python.
This works, if both statements are on the same line:
print("bla"); print ("bla bla")
+ 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
+ 2
if you write semicolon in python compiler will give error
- 1
No, I'm pretty sure you get interpreter errors if you put any semicolons after statements