Exercise: Check Monster Character Exists Description In this series of exercises, you will create functions to create, modify and examine dictionaries that represent characters in an animated film, and the cast members who voice the characters. The keys of the dictionary will be character names. The values in the dictionary will be voice actor names. For this exercise, you will create a function that checks if a character is already in the dictionary. Files monsterfunctions.py : set of functions to work with monster cast dictionaries. Function Name has_character Parameters monsters: a dictionary character: a string, the name of a character Action Checks if character is a key in monsters. Return Value True if character is a key in monsters, otherwise False. Examples monsters = create_monster_cast() monsters = add_cast_member(monsters, "Mike", "William Crystal") has_character(monsters, "Mike") -> True has_character(monsters, "Sully") -> False
Exercise: Check Monster Character Exists
Description
In this series of exercises, you will create functions
to create, modify and examine dictionaries that
represent characters in an animated film, and the
cast members who voice the characters. The
keys of the dictionary will be character names.
The values in the dictionary will be voice actor
names.
For this exercise, you will create a function that
checks if a character is already in the dictionary.
Files
- monsterfunctions.py : set of functions to work with monster cast dictionaries.
Function Name
has_character
Parameters
- monsters: a dictionary
- character: a string, the name of a character
Action
Checks if character is a key in monsters.
Return Value
True if character is a key in monsters, otherwise False.
Examples
monsters = create_monster_cast()
monsters = add_cast_member(monsters, "Mike", "William Crystal")
has_character(monsters, "Mike") -> True
has_character(monsters, "Sully") -> False
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images