Semicolons in Python?!

Muhimen - Aug 15 '20 - - Dev Community

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.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player