Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_switchcase.py
- def animal_sound(animal):
- sounds = {
- "cat": "Meow",
- "dog": "Woof",
- "cow": "Moo"
- }
- return sounds.get(animal, "*** Unlisted ***")
- # Test the function
- for animal in 'cat dog cow sloth'.split():
- print(animal_sound(animal))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement