The dictionary will store the names of the movies, and for each movie the dictionary value will be a list of show times.
I could not figure it out. Is that correct???
movie A: 9,11,15 movie B: 10,14,6 movie C: 11,13,19
dictionary={"moviesA":0, "moviesB":0, "moviesC":0}
showingtimes={"moviesA": 9, "moviesA": 11, "moviesA": 15, "moviesA": 21, "moviesB" : 10, "moviesB": 14, "moviesB": 16,
"moviesC": 11, "moviesC":13, "moviesC":19, "moviesC": 20, "moviesC": 21, "movieC":22}
Store it like :
data1={'movie A': [9,11,15], 'movie B': [10,14,6], 'movie C': [11,13,19]}
Now if you want to check by time you can do :
#which movies shows available at 11 ?
def check_by_time(time_mo):
movies_list=[]
for i, j in data1.items():
if time_mo in j:
movies_list.append(i)
return movies_list
print(check_by_time(11))
output:
['movie A', 'movie C']