Hey So I'm working on a problem that asks me to manipulate a dictionary by grabbing all the keys and values and formatting them into a single string for every key/value pair. I have to do this in one line, or so I think, the problem is better explained in the image.
1 Answer
I believe they would like you to write for country, pop in country_pop.items(): on line 7. However, you can do the entire thing in one line as well.
print('\n'.join([f'{key} has {value} people' for key, value in country_pop.items()])) 4