Dear Python experts,

I suppose I have the following Python code:

aList = [3, 5, 2, 4]

sorted(aList)
> [2, 3, 4, 5]

aList.sort()

aList
> [2, 3, 4, 5]

My understanding of each is:
1) function(variable) is manipulating a vector, I can do bList =
sorted(aList)
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!
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to