0% found this document useful (0 votes)
3 views1 page

List Vs Tuple Python

Uploaded by

gowri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

List Vs Tuple Python

Uploaded by

gowri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Difference Between List and Tuple in Python

In Python, list and tuple are both used to store a collection of items. However, they differ in mutability, syntax,

and use cases.

Feature List Tuple

Mutability Mutable - can be changed Immutable - cannot be changed

Syntax Uses [ ] Uses ( )

Methods Many (append, remove) Fewer methods

Performance Slightly slower Faster and memory-efficient

Use Case For changeable data For fixed data

Example Code:

my_list = [1, 2, 3]

my_list.append(4) # Works

my_tuple = (1, 2, 3)

# my_tuple.append(4) # Error: Tuples don't support this

Conclusion: Use lists when you need to modify data. Use tuples for fixed collections that should not change.

You might also like