DEV Community

Cover image for Semicolons in Python?!
Muhimen
Muhimen

Posted on

Semicolons in Python?!

I have been coding in Python for roughly about 2 year. And today, I just found out YOU CAN USE SEMICOLONS IN PYTHON!! Isn't that a cool feature? I have never thought using them before.

So, what does semicolons(;) do in Python? Nothing. Uses of semicolons in Python is same as you would use in JavaScript. Python won't throw any syntax error if your "pinky" presses the ; button by mistake. It doesn't matter if you put a semicolon at the end of the statement or not, Python will ignore it, and simply execute the script. Here is a simple example of it.

for i in range(50):
    print(i);
Enter fullscreen mode Exit fullscreen mode

But why should you use semicolons?

Well, there is no reason to use semicolons in Python. Semicolon was introduced in Python to help other people migrating from someother programming languages that requires a semicolon at the end of the statements. It's not a good practice to use it in Python.

Top comments (2)

Collapse
 
iceorfiresite profile image
Ice or Fire

You can play in traffic too but it's not a good idea lol

Collapse
 
evilprince2009 profile image
Ibne Nahian

Hearing for the first time.
So Python adopting semicolon ? LOL !