14. Why can't I do two list functions in one line, to a list in a dictionary?



If i write the code I have included in this post. I get this error.

Traceback (most recent call last):
File "python", line 15, in
AttributeError: 'NoneType' object has no attribute 'remove'

If I write the other code I have included in this post, it works fine. Why is that?

I expected to be able to execute two list functions in one line.

#This works

#This doesn't work. Why is that?


calling sort function returns None instead of the expected sorted list as sorting takes places in the same list. You can execute multiple functions on the same list provided the return value of one operation is the same or another list.