You have a number and you need to determine which digit in this number is the biggest.
Input: A positive int.
Output: An Int (0-9).
Example:
max_digit(0) == 0
max_digit(52) == 5
max_digit(634) == 6
max_digit(1) == 1
max_digit(10000) == 1
->Solve it
def max_digit(number: int) -> int:
return int(max(str(number)))
def max_digit(number: int) -> int:
return int(max(str(number)))
def max_digit(number: int) -> int:
return max([int(x) for x in str(number)])
max_digit = lambda number: int(max(str(number)))
lambda 인자 : 표현식
링크 : wikidocs.net/64
if __name__ == '__main__':
print("Example:")
print(max_digit(0))
# These "asserts" are used for self-checking and not for an auto-testing
assert max_digit(0) == 0
assert max_digit(52) == 5
assert max_digit(634) == 6
assert max_digit(1) == 1
assert max_digit(10000) == 1
print("Coding complete? Click 'Check' to earn cool rewards!")
lambda 인자 : 표현식
'프로그래밍 공부' 카테고리의 다른 글
12. Python, CheckiO Elementary_Beginning Zeros (0) | 2020.10.22 |
---|---|
**11. Python, CheckiO Elementary_Split Pairs (0) | 2020.10.22 |
9. Python, CheckiO Elementary_Replace First (0) | 2020.10.22 |
8. Python, CheckiO Elementary_All Upper I (0) | 2020.10.22 |
** 7. Python, CheckiO Elementary_Remove All Before (0) | 2020.10.22 |
댓글