Advertisements
Advertisements
Question
Differentiate between tuple and list.
Distinguish Between
Advertisements
Solution
| List | Tuple |
|---|---|
| A list is a sequence of values of any type. | A tuple is a sequence of values of any type. |
It is enclosed in square brackets []. |
It is enclosed in parentheses (). |
| It is mutable; values in the list can be modified. | It is immutable; values of tuples cannot be changed in place. |
List methods include append(), extend(), insert(), remove(), sort() and reverse(). |
Tuple functions include len(), max(), min() and tuple(). |
Example: [10, 20, 30] |
Example: (10, 20, 30) |
shaalaa.com
Is there an error in this question or solution?
