Monday, 23 January 2017

DIFFERENCE BETWEEN LIST AND TUPLE IN PYTHON

LIST
TUPLE

List objects are mutable objects
Tuple objects are immutable objects
Iterating the list is slower
Iterating the tuple is faster
List objects are not used as a keys for the dictionary
The tuple objects which contains immutable objects can be used as key for the dictionary
If the data changes frequently, then it is recommended to represent that data by using list
If the data doesn’t change then it is recommended to represent the data by using tuple

No comments:

Post a Comment