Advertisements
Advertisements
Question
What advantages do tuples have over lists?
Short/Brief Note
Advertisements
Solution
The advantages of tuples over the lists are as follows:
- Tuples are faster than lists.
- Tuples make the code safe from any accidental modification. If data is needed in a program that is not supposed to be changed, then it is better to put it in ‘tuples’ than in ‘list’.
- Tuples can be used as dictionary keys if it contains immutable values like strings, numbers, or other tuples. ‘Lists’ can never be used as dictionary keys as ‘lists’ are mutable.
shaalaa.com
Concepts of Tuples in Python
Is there an error in this question or solution?
