+ 1
Do we need to give semicolon at the end of statement in python??
7 ответов
+ 5
Semicolon aren't required at the end of a statement in Python, but doing so won't hurt. Infact, they can be used to write multiple statements in the same line like
a = 5
b = 6
Is equivalent to
a = 5 ; b = 6
Some interesting stuff here:
https://stackoverflow.com/questions/28883858/python-semicolon-does-make-a-difference
+ 3
Echo Echo, that's funny, I didn't know yet that writing the same assignments in one or two lines may make a difference!
Although that's probably one of the phenomena we shouldn't rely on when writing code?
+ 3
Watch out, though, James: Code can get harder to read that way!
+ 2
Please continue to study your tutorial for a bit!
Fundamental questions like these will naturally be answered.
+ 2
Zen of Python says:
Readability counts.
PEP8 says:
Compound statements (multiple statements on the same line) are generally discouraged.
+ 1
Experiment. Explore. Don't be afraid to mess up a code by altering it and playing with it.
As you go through the lessons write little example codes to try out what you've just learned. Write lots of them. They won't get you up votes and badges but they will give you the experience necessary for the commands, functions and syntax to begin to become second nature.
And by experimenting you discover options you may never have found in books or tutorials.
Play. Explore. Experiment.
Develop! Develop! Develop!
0
Echo Echo thanks for the note on same line multi statements. You just helped me condense some of my programs 🙆