Skip to content

Instantly share code, notes, and snippets.

@kurzweil777
Created June 1, 2020 10:07
Show Gist options
  • Save kurzweil777/5800d557de92f6412a2a523284a0abc9 to your computer and use it in GitHub Desktop.
Save kurzweil777/5800d557de92f6412a2a523284a0abc9 to your computer and use it in GitHub Desktop.
Exercise_from_CodeWars
def high_and_low(numbers):
"""In this little assignment you are given a string of space separated numbers, and have to return the highest
and lowest number. """
int_numbers = [] # Creating a list for inputting integers
for number in numbers.split(): # Iteration through the string with numbers
int_numbers.append(int(number)) # Writing integers into a created list
new_numbers = sorted(int_numbers) # Sorting numbers
return str(new_numbers[-1]) + " " + str(new_numbers[0]) # Returning the result
print(high_and_low("542 9 3 4 -214")) # return "542 -214"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment