Adding a Choice
Challenge 1-6: Logic with If Statements
Challenge 1-6: Logic with If Statements
Now let’s add one extra choice to our real-life if statements:
"If the dog is hungry, feed it some lunch.
Or else feed it in an hour.”
"If we have chocolate biscuits, I'll have two.
Or else I'll just have a banana."
To add a choice in our code we would use the else clause:
>>> if myname == "Ginger":
... print("Hi Ginger!")
... else:
... print("Impostor!")