Skip to content

Python Tuple #243

Closed Answered by anyemoka
0xAchilles27 asked this question in Q&A
Nov 10, 2023 · 14 comments · 4 replies
Discussion options

You must be logged in to vote

A tuple is a built-in data type in Python that is an immutable sequence that is used to store an ordered set of data. Tuples are very similar to lists, but they have some important differences.
Tuples are represented by parentheses (), with elements separated by commas. For example, the following code defines a tuple of three elements:
my_tuple = (1, 2, 3)

The elements of a tuple can be any data type, including numbers, strings, lists, dictionaries, and so on. Elements in a tuple can be accessed by an index, which starts at 0, for example:
print(my_tuple[0]) # Output: 1

However, tuples are immutable, which means that once a tuple is created, no elements within it can be added, removed, or…

Replies: 14 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@whshyaige
Comment options

@114514lpy
Comment options

Comment options

You must be logged in to vote
1 reply
@0xAchilles27
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@0xAchilles27
Comment options

Answer selected by 0xAchilles27
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet