Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Recap
4. Modifying elements in a dictionary
Counting with dictionaries
Grouping with dictionaries
Linking with dictionaries
Summary

Instruction

Excellent! Now let's try to modify actual dictionary elements.

Exercise

Jessica plays a game in which she serves restaurant customers – e.g., she plays a waitress. You are given a dictionary with:

  • the names of customers sitting in the restaurant right now (the keys).
  • the waiting time in minutes – how long ago the customer came into the restaurant (the first value in the tuple).
  • status – if a given person is still waiting for food ('still waiting'), has gotten their food ('got the food :)'), or has left after waiting too long ('left without eating :('). This is the second value in the tuple.

The last case ('left without eating :(') happens when customer waits for food for 20 minutes or more.

Update the status of those customers who have waited for their food for 20 minutes or more (and their status is not 'got the food :)'). Also, count how many customers have left. Print the following information:

{} customers left.

Stuck? Here's a hint!

Remember to unpack the dictionary values inside the for loop.

Count the number of modified elements and all customers that have a 'left without eating :(' status.