0

i have small doubt plz clarify. In python I know list is mutable,tuple is immutable,why?

i have small doubt plz clarify. In python I know list is mutable,tuple is immutable but elements can change in list, elements can't change in tuple,why

10th Dec 2017, 4:56 PM
lokesh reddy
lokesh reddy - avatar
2 Réponses
+ 7
list are dynamic so can add items while tuple are fixed so can't add items.
10th Dec 2017, 5:04 PM
Nilavarasan
Nilavarasan  - avatar
+ 5
Tuples are more efficient for storing data that youre not gonna change, for example coordinates of specific places on a map. Lists, on the other hand, are more useful if you do actually want to change the data inside of them. Also, since tuples are immutable, they can be used as dictionary keys.
10th Dec 2017, 5:03 PM
Supersebi3
Supersebi3 - avatar