In the lessons so far we have not been told to use semicolons nor has the editor given me error about it. In all of the other languages I have learned they required a semicolon at the end of a statement. Why is this not the case when writing in Python?
StackOverflow.com is a good site to find information about coding. Here is a explanation of Python and semicolons:
It makes getting the code from idea to implementation so much quicker that a lot of times you can go from idea to working project before someone in C can even get a prototype working.
The there are only a few things that reuire a direct hey this here has ended statement which in python is the
: and you use it at the end of loop statements and if/else statements, also try is another one off the top of my head that requires it.
for x in range(5): print(x) if 1 ==1: print(True) while True: return False try: int(raw_input("Enter a number") except ValueError as error: print(error, ValueError) finally: print("Finished")
All the above are examples of where you need to explicitly tell the syntax hey this statement is over. Most of the other times it is over when the word is done being used.
rather you can be used as a delimiter when you wish to write multiple statements on one line
print "semicolon after"; x = "delimeter"; print x;
I always forget about the semicolon funness, it is generally bad form in python to use it. While you can use it it just is not good form at all.