Tuple


Collection Type Ordered Mutable Duplicate Elements Indexing Example
Tuple Yes No Yes Yes (2, "beam_12", 42.1234, False)


tuple is a collection that is ordered and unchangeable. It allows to duplicate members.

# To create (instantiate)
a = (2,beam_12,42.1234,True,False)

# To retrieve an element
b = a[2]  # 42.1234

# To remove an element
impossible!

# To insert an element
impossible!


🦊 Remember that tuples are different than lists and depending on the situation they can offer advantages:


🛠 Exercise


🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍

Solution:

🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍