[Tutor] What's the difference between sort(aList) and aList.sorted()

C W tmrsg11 at gmail.com
Wed Jul 26 14:40:17 EDT 2017

Dear Python experts,

I suppose I have the following Python code:

aList = [3, 5, 2, 4]

> [2, 3, 4, 5]


> [2, 3, 4, 5]

My understanding of each is:
1) function(variable) is manipulating a vector, I can do bList =
2) object.method() is permanently changing it, I don't even need to assign
it in #1.

Why is there both? They do the same thing. Is if I unknowingly hit the
keyboard with the aList.sort(), then the "damage" is permanent.

Thank you!

More information about the Tutor mailing list