Find highest and lowest number from the string of numbers

后端 未结 5 862
慢半拍i
慢半拍i 2021-01-21 09:44

I\'m trying to write a function that returns the highest and lowest number in a list.

def high_and_low(numbers):

    return max(numbers), min(numbers)

print(hi         


        
5条回答
  •  旧时难觅i
    2021-01-21 10:39

    Another (faster) way using mapping:

    def high_and_low(numbers: str):
        #split function below will use space (' ') as separator
        numbers = list(map(int,numbers.split()))
        return max(numbers),min(numbers)
    

提交回复
热议问题