filmov
tv
What are the key difference between lists and tuples in python with examples

Показать описание
What are the key difference between lists and tuples in python
Sno. LIST TUPLE
1 Lists are defined using square brackets [ ] Tuples are defined in round brackets ( )
2 Lists are mutable Tuples are immutable
3 Lists are many built-in methods: Since list is mutable list having additional functionalities like insert , sort and pop are available. Tuples are less in-built methods: tuples doesn’t support any of this functionalities
4 lists having variable length Tuples has fixed length
5 The Lists are less memory efficient than the tuples The tuples are more memory efficient than the list
Sno. LIST TUPLE
1 Lists are defined using square brackets [ ] Tuples are defined in round brackets ( )
2 Lists are mutable Tuples are immutable
3 Lists are many built-in methods: Since list is mutable list having additional functionalities like insert , sort and pop are available. Tuples are less in-built methods: tuples doesn’t support any of this functionalities
4 lists having variable length Tuples has fixed length
5 The Lists are less memory efficient than the tuples The tuples are more memory efficient than the list