Debugging python code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Debugging python code?

I need help debugging this code , All the info is here: https://code.sololearn.com/c0sWC7RbU84N/?ref=app Goodluck

21st Oct 2021, 6:34 AM
Richard
Richard - avatar
2 Answers
+ 2
Since you want "-42 9" (largest then smallest), you need the iterable to be sorted in descending order. numbers = list( map( int, numbers.split() ) ) # convert all split results to `int` numbers.sort( reverse = True ) # sort in descending order
21st Oct 2021, 6:50 AM
Ipang
+ 2
sort method sorts the string alphabetically. Since you are using numbers as string you can use key as int, means: numbers.sort(key=int) It will convert string to integers and then compare it to others
21st Oct 2021, 6:59 AM
Carlos
Carlos - avatar