Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A dictionary has hello as hola, cat as gato and dog as perro. Translate the words hello, cat, bird and dog. A word that is not in the dictionary should stay as it is.
The default of get can be the thing that you looked up.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Plan. Use get with the word itself as the default.
dictionary.get(word, word) gives the translation if there is one, and the word itself if not.
Answer: hola, gato, bird and perro.
Log in to join the discussion.
Loading…