본문 바로가기
프로그래밍 공부

10. Python, CheckiO Elementary_Max Digit

by 응_비 2020. 10. 22.

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 인자 : 표현식

댓글