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))
2 Réponses
+ 7
Just use the optional default return value argument.
print(books.get(book, "Not Found"))
+ 1
Thanks i understand