I thought in Python I am allowed to perform method chaining.
basket = [1,3,2,4,6,8]
basket.append(7)
basket.sort()
basket.reverse()
This works.
basket.append(7).sort().reverse()
This does not.
AttributeError: 'NoneType' object has no attribute 'sort'
I am not sure what is going on here, but I assume that happens because in place methods result in "NoneType" result = basket.sort()
and therefore the second method will be performed on the result and not the original object.
Can anyone help me how to do these operations without writing a new line for each method?