Tuples (Cheat Sheet)

Tuples (Cheat Sheet)

Tuples are similar to lists:

Lists Tuples
mutable immutable
use square brackets to identify use parentheses to identify

Tuples tend to be faster since they are immutable

Example

sentence = ( "This", "is", "a", "tuple")
print(sentence[1])
sentence[3] = "phrase"

An empty tuple:

sentence = ()
Stefan Schneider Tue, 05/03/2022 - 17:33