About this video

Episode 5 of the creator’s Python series builds on if/else flow control with two new concepts taught through a coffee-shop robot barista lab. First, nested ifs: if a customer is named Ben, the program asks whether he is evil, and only kicks him out if a second, indented if confirms evil_status equals yes; a nested else welcomes a non-evil Ben. He stresses that indentation determines which if or else a block belongs to, and that nested conditions require all of them to be true. Second, elif (spoken as ’elif’/’e-if’) for the menu-pricing problem: instead of many separate ifs — which can overwrite each other if an else resets the price — a single if/elif chain sets different prices per drink (the examples include a frappuccino at $13 versus the earlier flat $8, black coffee at $3, and espresso at $5), ending with an else for items not sold. He shows debugging a NameError by giving the final else a price value, and sets a challenge: make a latte with whipped cream cost $11 instead of the standard $9.

Key takeaways

  • Nested ifs run inner checks only when the outer condition is true
  • Indentation in Python ties code blocks and else clauses to their if
  • elif chains test alternatives in order without needing separate ifs
  • A stray else on separate ifs can overwrite a correct earlier price
  • End an if/elif chain with else to handle unmatched input safely

Episode details: published February 17, 2022 · 17:56 long. Summary written by Self Growth Videos from the episode itself. Business results and any income figures mentioned are NetworkChuck’s own claims, shared for education — they are not typical or guaranteed.


← Previous: i HACKED my wife’s web browser (it’s SCARY easy!!) · Next: make CRAZY money in tech (top 5 Entry-Level Certs) →

All NetworkChuck videos · NetworkChuck profile · NetworkChuck on YouTube

Sister brand · Vacation Club Promo

All-inclusive resort stays from $435

Qualified couples: promotional Mexico and Caribbean packages at real resorts. Short presentation during your stay — enjoy the rest of the trip.

Qualifications apply · presentation during stay · no purchase required

Subscribe YouTube Suggest