Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 1
Why doesnโt it work?
def remove_smallest(numbers): c = min(numbers) numbers.remove(c) return numbers
4 Answers
+ 2
If numbers is a list, then you should not mutate (change) it, because that might mess with the test validation. Make a copy or use a list comprehension.
0
What wrong you getting there?
Post full code..
0
Jayakrishna๐ฎ๐ณ โคโขโ ๐๐ข๐ข๐๐จ ๐๐ก๐๐ฒ๐๐ฅ โโขโค Itโs a kata from codewars. Itโs supposted to remove the smallest number from the list, but it produces an error and I donโt know why
0
What is the error you not mentioned?
Aleksandra Lewandowska
If this is full code, then you are defined function. But not calling that function to work..
So it should be like
def remove_smallest(numbers):
c = min(numbers)
numbers.remove(c)
return numbers
l = [1,2,3,4,5] #an example, you take here input.
print( remove_smallest(l)) #calling function, displays return list
#Output : [2,3,4,5]