Game Development Reference
In-Depth Information
while guesses < 10:
if number == 42:
print('Hello')
Text Wrapping in This Topic
Some lines of code are too long to fit on one line on the page, and the text of the code
will wrap around to the next line. When you type these lines into the file editor, enter the
code all on one line without pressing Enter.
You can tell when a new line starts by looking at the line numbers on the left side of the
code. For example, the code below has only two lines of code, even though the first line
wraps around:
1. print('This is the first line! xxxxxxxxxxxxxxx
xxxxxxxxxxxx')
2. print('This is the second line! ')
Tracing the Program Online
You can visit http://inventwithpython.com/traces to see a trace through each of the
programs in this topic. Tracing a program means to step through the code one line at a time,
in the same way that a computer would execute it. The traces web page has notes and
helpful reminders at each step of the trace to explain what the program is doing, so it can
help you better understand why these programs work the way they do.
Checking Your Code Online
Some of the games in this topic are a little long. Although it is very helpful to learn
Python by typing out the source code for these games, you may accidentally make typos
that cause your game programs to crash. It may not be obvious where the typo is.
You can copy and paste the text of your source code to the online diff tool on the topic's
website. The diff tool will show any differences between the source code in the topic and
the source code you've typed. This is an easy way of finding any typos in your program.
Copying and pasting text is a very useful computer skill, especially for computer
programming. There is a video tutorial on copying and pasting at this topic's website at
http://inventwithpython.com/videos/.
The online diff tool is at this web page: http://inventwithpython.com/diff. A video
Search WWH ::




Custom Search