Semicolons in Python?!
Muhimen

Muhimen @muhimen123

About: Nothing more than a programmer nothing less than a programmer. Loves to solve Rubik's cubes in spare time.

Location:
Bangladesh
Joined:
Nov 21, 2019

Semicolons in Python?!

Publish Date: Aug 15 '20
10 2

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.

Comments 2 total

  • Ice or Fire
    Ice or FireAug 17, 2020

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

  • Ibne Nahian
    Ibne NahianAug 24, 2020

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

Add comment