반응형
You ask a small girl,"How old are you?" She always says, "x years old", where x is a random number between 0 and 9.
Write a program that returns the girl's age (0-9) as an integer.
Assume the test input string is always a valid string. For example, the test input may be "1 year old" or "5 years old". The first character in the string is always a number.
Solution:
def get_age(age):
def get_int(age):
return int(age[0])
return get_int(age)
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1115. Reversed Strings (0) | 2022.11.15 |
---|---|
1114. Exclamation marks series #6: Remove n exclamation marks in the sentence from left to right (0) | 2022.11.14 |
1112. Sum of Multiples (0) | 2022.11.13 |
1111. Grasshopper - Debug sayHello (0) | 2022.11.12 |
1110. No oddities here (0) | 2022.11.10 |