My code marked correct without me changing it yet?

it marks ok without any solution and dont know how to solve it since i cant see if everythong is ok or not

A for loop to iterate over a dictionary and print out the key-value looks something like this…

for key in dictionary:
    print ("Women make up {percentage} percent of {occupation}.".format(percentage=dictionary[key], occupation=key))

The above iterates over only the keys in the dictionary, so we need to subscript it to poll the value.

If this lesson is about dict.items() then the loop will look like so,

for key, value in dictionary.items():
    print ("Women make up {percentage} percent of {occupation}.".format(percentage=value, occupation=key))

The above works because it is unpacking a tuple on each iteration. If we examine the array that items() returns we can see the tuples…

[
  ('CEO', 28), 
  ('Engineering Manager', 9), 
  ('Pharmacist', 58), 
  ('Lawyer', 37), 
  ('Aerospace Engineer', 9)
]

https://repl.it/@mtf/Get-All-items

1 Like

thank you! that makes all sense now

1 Like