← Back to list

Difference between list and tuple?

List and Tuple are Python data structures used to store multiple items. However, they differ in several ways.

Nivethabaskar · 2026-06-08 05:23 · 0 claps · 0.8 min read
#data-science #lists #tuples #machine-learning #python
Open on Medium ↗
Wiki topics: ML · Machine Learning EDU · Education & Learning 💻 · Programming 🔬 · Science · General

Difference between list and tuple?

**List and Tuple** are Python data structures used to store multiple items. However, they differ in several ways.

  • A List is mutable, which means its elements can be added, removed, or modified after creation. A Tuple is immutable, meaning its elements cannot be changed once it is created.
  • Lists are created using square brackets [ ], while tuples are created using parentheses ( ).
  • Lists generally use more memory and are slightly slower compared to tuples.
  • Tuples are faster and more memory-efficient because they cannot be modified.
  • Lists are suitable for storing data that may change, whereas tuples are used for fixed data that should remain constant.

Example:

# List
fruits = ["apple", "banana", "orange"]
# Tuple
colors = ("red", "green", "blue")

In summary, use a list when you need flexibility to modify data, and use a **tuple** when you want data to remain unchanged throughout the program.


메타데이터
post_id
55bf6fbd14cd
slug
difference-between-list-and-tuple-55bf6fbd14cd
url
https://medium.com/@nivethabaskar88/difference-between-list-and-tuple-55bf6fbd14cd
canonical_url
https://medium.com/@nivethabaskar88/difference-between-list-and-tuple-55bf6fbd14cd
author_url
https://medium.com/@nivethabaskar88
status
ok
fetched_at
2026-07-15 03:30:49