Quick actions

cmd+k|ctrl+k

Navigation

Languages

Tuple-1

Snippet info

Language

Python

Visibility

public

Author

narutouzumakiramen18

Created

2026-05-08T02:01:58.803759Z

Updated

2026-05-08T06:01:38.903734Z

# Tuple
my_tuple = (1,2,3,4,5)
# methods similar to list!
print(my_tuple[1])
print(2 in my_tuple)
# Unlike list if we use a tuple we are specifying to not change the values in the tuple!
# When other programmer sees a tuple he knows that the values inside it are not going to be changed unlike a list.

# A dict can have tuple as a key.
user = {
    (1,2) : [1,2,3]
}
print(user[(1,2)])

# we can also have a new tuple a copy using indexing
new_tuple = my_tuple[1:3]
print(new_tuple)

INFO