Hardware Reference
In-Depth Information
DIGGING INTO THE CODE
In Adventure 3, you created conditions for the Scratch role-playing game using
an if…else block like the one in Figure 5-9. In Scratch, the blocks for each
part of a condition are automatically indented slightly for you within the if…
else block. You can easily see which parts of the condition need to be met by
how far they are indented. In Python code, you have to add indents to show
which lines of code are part of the conditional. Python code also uses the colon
( : ) to show where you might need to indent. Take a look at Figure 5-9 to com-
pare indentation in the if…else statements in Scratch and Python.
FIGURE 5-9 Using if…else statements in Scratch (top) and
Python (bottom)
Search WWH ::




Custom Search