0

How to assign NONE value (if key is not in dictionary) with „Book not found“ using get () method?

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() #change this part to use the .get() method print(books.get(book))

4th Dec 2020, 8:01 PM
Meerim Jeembaeva
Meerim Jeembaeva - avatar
1 Antwort
+ 2
oo thanks,I was trying to do twice, fist for key in dictionary, and second line separate . It was my mistake
4th Dec 2020, 8:16 PM
Meerim Jeembaeva
Meerim Jeembaeva - avatar