I have a list of dictionaries and I want to do a for each to find corresponding values.
My list:
my_list = [{'genre':'Dystopia', 'book':'Hunger Games'},
{'genre':'Fanstasy', 'book':'Harry Potter'},
{'genre':'Dystopia', 'book':'Divergent'}]
I want to get books corresponding to the genre.
Expected result:
for 'Dystopia' get 'Hunger Games', 'Divergent'
for 'Fantasy' get 'Harry Potter'
I am not sure how to go about it. I know I need a for loop but don't know what to do beyond that.
for x in my_list:
x['url']
Not sure what to add next.