
Lesson 01 · 10 min
Indentation, names, types as a habit
There are no block braces. A block is defined by indentation. You don't write the type up front, but the value still has one.
In Python a block isn't in { }. After : comes a new line and a 4-space indent. Mix tabs and spaces and you get an error, not "well, it almost works". A variable name doesn't carry a type: n = 1 can later become n = "one". The value has a type, not the box.
#is a comment to the end of the line.Nonemeans "nothing"; don't confuse it with0and"". In a conditionNoneis false.- A string and a number don't add silently:
"n=" + 1fails. You needstr(1)or an f-stringf"n={n}".
Check
Lock it in before you move on
1. How is the body of an
ifmarked in Python?2. What does
"n=" + 1do?3.
Noneis closer to