Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Python Tuples | Other Data Types in Python
Introduction to Python
course content

Course Content

Introduction to Python

Introduction to Python

1. First Acquaintance with Python
2. Variables and Types in Python
3. Conditional Statements in Python
4. Other Data Types in Python
5. Loops in Python
6. Functions in Python

book
Python Tuples

A tuple is a Python data type that stores multiple values, separated by commas and enclosed in parentheses. While tuples may seem similar to lists, they have key differences.

The main distinction is mutability: lists can be modified, but tuples cannot. For example, the .extend() method works on lists but not on tuples. Once created, a tuple's contents cannot be changed without creating a new one.

Tuples are also faster and more memory-efficient than lists, making them a good choice for storing fixed or sensitive data.

12345
# Create tuple US_Info = ("USA", 9629091, 331002651) # Printing tuple print(type(US_Info))
copy

Note

You can also transform an iterable object into a tuple with the tuple() function.

12345678
# Create a list list_variable = [1, 2, 3] # Convert it into a tuple tuple_variable = tuple(list_variable) # Print the type of the converted variable print(type(tuple_variable))
copy
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 6
We're sorry to hear that something went wrong. What happened?
some-alt