I want to randomly select a list from a list of lists. When I've tried this on my own, my program returns all of the lists with matching items in that slot. Is there a way to narrow this down?
For example, if I put in "action"
for mood
, since it's in item slot[1]
, it returns the 3 animes with "action"
in that slot. I also tried using random.choice()
in my print
function, but it only prints random items from each list that matches the mood
input.
from random import choice
# create a list of animes
animes = [['naruto', 'action', 'drama', 'series', 'comedy'],
['nagatoro', 'slice of life', 'comedy', 'series', 'romance'],
['one piece', 'action', 'comedy', 'series', 'drama'],
['netoge no yome', 'action', 'slice of life', 'series' 'comedy']
]
# input mood
print('What mood are you in?')
mood = input()
for item in animes:
if item[1]==mood:
print(mood + ' anime:' + item[0])