반응형
The wide-mouth frog is particularly interested in the eating habits of other creatures.
He just can't stop asking the creatures he encounters what they like to eat. But, then he meets the alligator who just LOVES to eat wide-mouthed frogs!
When he meets the alligator, it then makes a tiny mouth.
Your goal in this kata is to create complete the mouth_size method this method takes one argument animal which corresponds to the animal encountered by the frog. If this one is an alligator (case-insensitive) return small otherwise return wide.
Solution:
def mouth_size(animal):
return ["wide", "small"][animal.lower() == "alligator"]
def mouth_size(animal):
mouth = {'alligator':'small'}
return mouth.get(animal.lower(), 'wide')
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0101. Pillars (0) | 2023.01.01 |
---|---|
1231. For UFC Fans (Total Beginners): Conor McGregor vs George Saint Pierre (0) | 2022.12.31 |
1229. Parts of a list (0) | 2022.12.30 |
1228. Kata Example Twist (0) | 2022.12.28 |
1227. CSV representation of array (0) | 2022.12.27 |