File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -525,7 +525,30 @@ and executed:
525525 $ python3 python_intro.py
526526 Hey Sonja!
527527
528- See what happened there?
528+ See what happened there? ` elif ` lets you add extra tests that run if the previous tests fail.
529+
530+ You can add as many ` elif ` statements as you like after your initial ` if ` statement. For example:
531+
532+ ``` python
533+ volume = 57
534+ if volume < 20 :
535+ print (" It's kinda quiet." )
536+ elif 20 <= volume < 40 :
537+ print (" It's nice for background music" )
538+ elif 40 <= volume < 60 :
539+ print (" Perfect, I can hear all the details" )
540+ elif 60 <= volume < 80 :
541+ print (" Nice for parties" )
542+ elif 80 <= volume < 100 :
543+ print (" A bit loud!" )
544+ else :
545+ print (" My ears are hurting! :(" )
546+ ```
547+
548+ Python runs through each test in sequence and prints:
549+
550+ $ python3 python_intro.py
551+ Perfect, I can hear all the details
529552
530553### Summary
531554
You can’t perform that action at this time.
0 commit comments