Lesson 4

Using a While Loop


A conditional statement is something that will only happen if a certain condition is true. E.g. if it’s raining outside, I will bring an umbrella. You can think of them as little rules to follow

In Python, we introduce these statements in the form of if, elif, and else, statements. An if will do a section of code only if the chunk of conditional statement inside it is true

Since we had 3 actions that our pet can do, we want put an if or elif to check each possibility

Copy the code shown in the image to the side. Make sure that the ‘pass’ on line 25 is indented

Good programming considers all possible situations, which is why we have the else: pass statement, in case the user enters something other than one of the prompts.

Very simply this will check first if we entered in “1”, if not, it will check if we entered “2”, then three, then if we didn’t enter any of those things, it will skip