Basically, I have a list and I want to perform multiple functions on it at once. For example,
List = [1,2,3,4,5]
List.extend([1,2,3,4,5]).sort().reverse()
I would like the result to be [5,5,4,4,3,3,2,2,1,1].
I haven’t used Python in a while, but I know I’ve done something like this before. Is it something simple I’m missing or what?
It has to all be on one line by the way.
Most Python methods that mutate a container in-place return None
However your example can easily be handled in one line
Keeping in the spirit of the challenge, it’s not hard to chain the operations (because they always return
None)Here’s another way
And you can let your imagination run wild