Advertisements
Advertisements
प्रश्न
What advantages do tuples have over lists?
टीपा लिहा
Advertisements
उत्तर
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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
