← Back to challenges

Burglary Series (03): Is It Gone?

PythonHardstringsdata_structures

Instructions

Your spouse is not concerned with the loss of material possessions but rather with his/her favorite pet. Is it gone?!

Given a dictionary of the stolen items and a string in lowercase representing the name of the pet (e.g. "rambo"), return:

  • "Rambo is gone..." if the name is on the list.
  • "Rambo is here!" if the name is not on the list.

Note that the first letter of the name in the return statement is capitalized.

Examples

 items = {
  "tv": 30,
  "timmy": 20,
  "stereo": 50,
} ➞ "Timmy is gone..."
# Timmy is in the dictionary.

 items = {
  "tv": 30,
  "stereo": 50,
} ➞ "Timmy is here!"
# Timmy is not in the  dictionary.

items = { } ➞ "Timmy is here!"
# Timmy is not in the dictionary.

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Cricket Balls to Overs!