Lesson 3

Using a While Loop

On line 8 add in the code while (action != “-1”):

This loop will run for as long as the user doesn’t enter in “-1” for the action that they want to do. In effect, this will keep running as long as the user wants it to keep going.

The first thing we need is to prompt the user what they would like to do with their pet. Each choice will have a number value associated, i.e. enter 1 to Play with pet, -1 to quit, and so on.

On line 10, start with an indent. This is done by pressing the tab key Add the following code print(“What would you like to do?”)

Lines 11-14 will all consist of print statemnts involving our petName variable. Copy these lines of code from the picture to the side

Pause here, and make sure that their program is running properly, at the moment, it should just be a prompt, that will repeat until we enter “-1”