-3

I'm new to Python and Programming in general. I'm trying to get a head start for College come Summer Term. I'm trying to learn from this beginner's book and it cites the following code exactly as I'm putting it... I tried changing the space indent every which way but I still get this message. I understand I'm probably missing something here but I would appreciate the advice as to how I should proceed.

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)]


  >>> # Ghost Game
   ... from random import randint
   >>> print('Ghost Game')
   Ghost Game
   >>> feeling_brave = True
   >>> score = 0
   >>> while feeling_brave:
   ... ghost_door = randint(1, 3)
    File "<stdin>", line 2
    ghost_door = randint(1, 3)
             ^
   IndentationError: expected an indented block
    >>> ghost_door= randint(1, 3)
    >>> while feeling_brave:
    ... ghost_door= randint(1, 3)
    File "<stdin>", line 2
    ghost_door= randint(1, 3)
             ^
IndentationError: expected an indented block
>>> while feeling_brave:
... ghost_door = randint(1, 3)
  File "<stdin>", line 2
    ghost_door = randint(1, 3)
             ^
    IndentationError: expected an indented block
    >>> while feeling_brave:
    ... ghost_door = randint(1,3)
    File "<stdin>", line 2
       ghost_door = randint(1,3)
             ^
   IndentationError: expected an indented block
   >>> while feeling_brave:
   ... ghost_door =randint(1,3)
     File "<stdin>", line 2
    ghost_door =randint(1,3)
Joseph
  • 11
  • 1

2 Answers2

0

After a "while" statement, the interpreter shows you "...". You must the provide the indentation by typing four spaces at the start of your next line.

John Anderson
  • 35,991
  • 4
  • 13
  • 36
0

Add an indent by pressing [TAB] in front of your existing indentation on the line

... ghost_door = randint(1,3)

Currently, you have got:

while feeling_brave:
    ghost_door = randint(1, 3)

You have not got the "statements" for the loop as an indent, so the interpreter treats it as two consecutive commands. However, having

while feeling_brave:
    ghost_door = randint(1, 3)

tells the interpreter to execute your second line while the loop is running.

Xetrov
  • 127
  • 12