본문 바로가기
나는 이렇게 학습한다/Algorithm & SQL

1113. Parse nice int from char problem

by daco2020 2022. 11. 13.

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)