Why am I not required to have a semicolon at the end of anything so far?


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:


The reason for this is because python is about ease of use so all that extra stuff like in C#, C, C++ JavaScript is not needed because they syntax does not require it.

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):
if 1 ==1:
while True:
    return False
    int(raw_input("Enter a number")
except ValueError as error:
    print(error, ValueError)

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.


Unlike other languages like Java, JavaScript, PHP etc python does not require a semicolon to terminate statement but
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;


@albionsrefuge @rydan

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.


@zeziba Yeah sometimes when i do some work in Java and I return to python i mistakenly put semicolons when I am not supposed to. Haahah!! :grin: