When entering the source code yourself, do not type the line numbers that appear at the beginning of each line. For example, if you see this in the book:
1. number = random.randint(1, 20) 2. spam = 42 3. print('Hello world!')
You do not need to type the "1." on the left side, or the space that immediately follows it. Just type it like this:
number = random.randint(1, 20) spam = 42 print('Hello world!')
Those numbers are only used so that this book can refer to specific lines in the code. They are not a part of the actual program.
Aside from the line numbers, be sure to enter the code exactly as it appears. Notice that some of the lines don’t begin at the leftmost edge of the page, but are indented by four or eight or more spaces. Be sure to put in the correct number of spaces at the start of each line. (Since each character in IDLE is the same width, you can count the number of spaces by counting the number of characters above or below the line you're looking at.)
For example in the code below, you can see that the second line is indented by four spaces because the four characters ("whil") on the line above are over the indented space. The third line is indented by another four spaces (the four characters, "if n" are above the third line's indented space):
while spam < 10: if number == 42: print('Hello')