Median Function "TypeNone" Error


#1

Hi. I can't seem to get this median function to work, and it returns the following error message.

" median([4, 5, 5, 4]) resulted in an error: object of type 'NoneType' has no len()"

Any help would be appreciated. Thank you!


#2

One question immediately arises... Where is the if.


#3

That was a typo after some troubleshooting. I have updated the screenshot. :slight_smile:


#4

nums = nums.sort()

will be None since there is no return value. Use,

nums.sort()

or

nums = sorted(nums)