makispaiktis

High and Low

May 1st, 2021
622
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''
  2. In this little assignment you are given a string of space separated numbers
  3. and have to return the highest and lowest number.
  4. Example:
  5. high_and_low("1 2 3 4 5")  # return "5 1"
  6. high_and_low("1 2 -3 4 5") # return "5 -3"
  7. high_and_low("1 9 3 4 -5") # return "9 -5"
  8. '''
  9.  
  10. def highLow(numbers):
  11.     NUMS = numbers.split(" ")
  12.     nums = [int(NUMS[i]) for i in range(len(NUMS))]
  13.     nums = sorted(nums)
  14.     return (str(nums[len(nums)-1]) + " " + str(nums[0]))
  15.  
  16.  
  17. # MAIN FUNCTION
  18. print(highLow("1 2 -3 4 -5"))
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×