0

I want to print ”Not Found" if boook not in dictionary? i did all the cases right but... unable to print Not found

books = { "Life of Pi": "Adventure Fiction", "The Three Musketeers": "Historical Adventure", "Watchmen": "Comics", "Bird Box": "Horror", "Harry Potter":"Fantasy Fiction", "Good Omens": "Comedy" } book = input() print(books.get(book))

22nd Feb 2021, 6:25 AM
Rahul Prasad
Rahul Prasad - avatar
2 odpowiedzi
+ 7
Just use the optional default return value argument. print(books.get(book, "Not Found"))
22nd Feb 2021, 6:44 AM
Ipang
+ 1
Thanks i understand
22nd Feb 2021, 6:49 AM
Rahul Prasad
Rahul Prasad - avatar