¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
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))
1 Respuesta
+ 2
oo thanks,I was trying to do twice, fist for key in dictionary, and second line separate . It was my mistake