Learn Before
Concept

Tuple

  • A tuple is a data structure that can store items within a single variable.
  • The items in a tuple are ordered (indexed) and are immutable (cannot be changed).
  • Tuples can have duplicate items.
  • To create a tuple, surround items (separated by commas) with parentheses. Ex:
tuple = ('apple', 34, 'banana')
  • To access an element inside a tuple, use the tuple name along with square brackets and the desired index. Ex:
tuple[1] # access tuple index 1, which is 34.

0

2

Updated 2025-10-06

Tags

Python Programming Language

Data Science

Foundations of Large Language Models Course

Computing Sciences

Related