What are the differences between Lists and Tuples?
Differences between Lists and Tuples are listed below:
Lists are comma separated sequence of items that have the items inside the square brackets [ ] and items are dealt individually.
Tuples are comma separated sequence of items and are enclosed by parentheses ( ) and is dealt as coherent unit.
Lists are mutable i.e. data can be changed after runtime.
Tuples are immutable i.e. data cannot be changed when set after runtime.
List consumes less memory.
Tuple consumes more memory compared to list.
List is better for performing operations such as insertion and deletion.
Tuple is better for accessing the elements inside it.
Implication of iterations in list is time-consuming.
Implication of iterations in Tuple is comparatively faster than list.
Unexpected changes and errors are more likely to occur in List as it is mutable.
Tuple is hard to make changes so less error prone.