This is an archived version of the course. Please see the latest version of the course.

Python vs. Java - Braces

Curly braces are not used in Python for marking blocks.

Instead, Python uses a combination of colon (:) and indentations to indicate a block.

Therefore, unlike in Java, indentation is compulsory in Python. But then again, you should be indenting your code anyway whether it is Python or Java!

You can use spaces or tabs to indent your code (four spaces is officially recommended).

You must however NOT mix spaces and tabs in your code. This will result in a syntax error. Pick one and be consistent.

Simple guessing game - Java vs Python