Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- In this little assignment you are given a string of space separated numbers
- and have to return the highest and lowest number.
- Example:
- high_and_low("1 2 3 4 5") # return "5 1"
- high_and_low("1 2 -3 4 5") # return "5 -3"
- high_and_low("1 9 3 4 -5") # return "9 -5"
- '''
- def highLow(numbers):
- NUMS = numbers.split(" ")
- nums = [int(NUMS[i]) for i in range(len(NUMS))]
- nums = sorted(nums)
- return (str(nums[len(nums)-1]) + " " + str(nums[0]))
- # MAIN FUNCTION
- print(highLow("1 2 -3 4 -5"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement