Light Mode
Dark Mode
Understanding the function

I was trying to solve this without the forum however I could not get the sorted function to work. My code was

def checkio(numbers_array: tuple) -> list:

lst = []
for number in numbers_array:
    lst.append(number)
sorted(lst, key=abs)
return lst

I couldn't get by the first challenge as it kept returning the original list (-20, -5, 10, 15). I eventually solved it using the result = sorted(numbers_array, key-abs) solution. I'm not sure what my original code was missing.

Created: March 30, 2019, 3:01 p.m.
Updated: Jan. 21, 2021, 8:54 p.m.
0
8
User avatar
reddawnfreedom