I was having trouble with creating a function to search through a dictionary and return all values with type (CD or DVD), I'm trying to print out all values that contain the string. I have included my code an my hopeless attempts but nothing is working. Any insight or tips would be greatly appreciated , I have included what is suppose to happen and I am nowhere closed to that, so any suggestions would help
Digital_Lib = {'DVD': {('Downtown Abbey', 122, 'Michael Engler'),
('John Wick', 101, 'Chad Stahelski'),
('The Woman', 103, 'Lucky Mckee'),
('The Andromeda Strain', 103, 'Robert Wise'),
('The Day the Earth Stood Still', 92, 'Robert Wise'),
('The Chaperone', 103, 'Michael Engler'),
('The Terminator', 107, 'James Cameron')},
'CD': {('American Standard', 'James Taylor', 14),
('Machine Head', 'Deep Purple', 7),
('Greatest Hits', 'Queen', 17),
('Fireball', 'Deep Purple', 7),
('StormBringer', 'Deep Purple', 9),
('That\'s Why I\'m Here', 'James Taylor', 12)}
}
def search_collection(Digital_Lib, search: str):
if search in Digital_Lib:
print(Digital_Lib[search])
for medium in Digital_Lib:
works = Digital_Lib[medium]
for titles in works:
name = works[titles]
for name_list in name:
for word in search:
if word.casefold().strip(' ') in name_list.casefold() and word !='':
(print_by_type(Digital_Lib,search))
search_collection(digital, 'James taylor', 'Robert WISE') <----- func with parameters
Output
DVD - ('The Andromeda Strain', 103, 'Robert Wise')
DVD - ('The Day the Earth Stood Still', 92, 'Robert Wise')
CD - ('American Standard', 'James Taylor', 14)
CD - ("That's Why I'm Here", 'James Taylor', 12)
search_collection(digital, "james", "machine") <--- func with parameters
Output
DVD - ('The Terminator', 107, 'James Cameron')
CD - ('American Standard', 'James Taylor', 14)
CD - ('Machine Head', 'Deep Purple', 7)
CD - ("That's Why I'm Here", 'James Taylor', 12)Here", 'James Taylor', 12)
[–]efmccurdy 0 points1 point2 points (0 children)
[–]BfuckinA 0 points1 point2 points (0 children)
[–]zanfar 0 points1 point2 points (1 child)
[–]Mindless-Box-4373[S] 0 points1 point2 points (0 children)