$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #232

Which fix removes the bug?

prices = {'tea': 2, 'jam': 5}
for name, cost in prices:
    print(name, cost)
  1. Loop over prices.keys()
  2. Loop over prices.values()
  3. Loop over enumerate(prices)
  4. Loop over prices.items()
Iterating a dict yields only its keys; items() yields (key, value) pairs to unpack.
Play Problem Solving ▸