- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between List and Tuples in Python.
List
List is a container to contain different types of objects and is used to iterate objects.
Example
list = ['a', 'b', 'c', 'd', 'e']
Tuples
Tuple is also similar to list but contains immutable objects. Tuple processing is faster than List.
Example
tuples = ('a', 'b', 'c', 'd', 'e')
Following are the important differences between List and Tuple.
Sr. No. | Key | List | Tuple |
---|---|---|---|
1 | Type | List is mutable. | Tuple is immutable. |
2 | Iteration | List iteration is slower and is time consuming. | Tuple iteration is faster. |
3 | Appropriate for | List is useful for insertion and deletion operations. | Tuple is useful for readonly operations like accessing elements. |
4 | Memory Consumption | List consumes more memory. | Tuples consumes less memory. |
5 | Methods | List provides many in-built methods. | Tuples have less in-built methods. |
6 | Error prone | List operations are more error prone. | Tuples operations are safe. |
Advertisements