'The use of a semicolon in python?
So what is the use of the semicolon (;) in python? All it does is separate multiple statements. I can't seem to find any practical use for the semicolon. If you are going to use a semicolon, then why not just put the multiple statements on multiple lines? If you want to define multiple variables on one line, you could always do: x, y = 0, 1 or something along those lines. The only time I can find a use for this is if you are using the terminal and you want to execute a command in python (for instance: python3 import random; print(random.randint(1, 10))). Even now, you can always use the python shell with python3 and then execute the code you want. It would be greatly appreciated if someone could show me a practical example of a semicolon.
Thanks!
Solution 1:[1]
It basically just denotes separation and is a leftover from older programming languages.
Solution 2:[2]
see example usage in book: Python Data Science Handbook
plt.plot(x, y ,'o', color = 'black');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nomeal |
| Solution 2 | Judy |
