-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson 3 names #14
Copy link
Copy link
Open
Description
-
I am updating all instances of "Alice" to "Anja" and "Bob" to "Noor".
-
A continuity question. The following lesson / code takes place after Exercise 2, where
my_namechanges.
elifStatements
Somewhat similarly to else, elif (short for “else if”) allows us to check multiple conditions in a sequence. The elif block will only be evaluated if the previous if or elif conditions were False. This allows us to check for multiple conditions without nesting multiple if statements. For example:
# Check if my_name matches 'Anja'
if my_name == 'Anja':
# If true, print this message
print('Hello, Anja!')
# Otherwise, check if my_name matches 'Noor'
elif my_name == 'Noor':
# If true, print this message
print('Hello, Noor!')
# Otherwise
else:
# Print this message
print("You aren't Anja or Noor!")
In the lesson, this code is interpreted as "Hello, Anja!" However, if the participants have done the exercises, they have now updated my_name to "Noor". Is it better to use a different variable in the exercise to avoid confusion?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels