Tuples in Python
Tuples are ordered collections similar to lists, but with one key difference: they are immutable. Once created, you cannot change their content.
Tuples are useful when you want to ensure data stays the same, or when you need a lightweight, fast collection.
Creating Tuples
Use parentheses () – comma is what really creates a tuple.
Accessing Tuple Items
Same as lists – by index.
Immutability
You cannot modify tuples – no append, remove, or item assignment.
Packing and Unpacking
Create tuples by packing values, extract with unpacking.
Tuple Methods
Only count() and index() – because tuples are immutable.
When to Use Tuples
- Fixed data that shouldn't change (like coordinates)
- As dictionary keys (tuples are hashable)
- Returning multiple values from functions
- Lightweight records
Quick Quiz
Wir haben die Materialien überprüft, dennoch können Fehler vorkommen. Der Inhalt dient ausschließlich Bildungszwecken, daher verwende ihn auf eigene Verantwortung und überprüfe ihn bei Bedarf mit anderen Quellen.
✨ Frag Lara — deine KI-Lernpartnerin
Entsperre personalisierte Lernunterstützung. Lara kann Lektionen erklären, Themen zusammenfassen und deine Lernfragen beantworten — verfügbar ab dem Go-Tarif.
Lara hilft dir, schneller zu lernen — exklusiv für ReadyTools Go-, Plus- und Max-Mitglieder.


