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
Hemos revisado y comprobado los materiales, pero aún pueden existir errores. El contenido se ofrece únicamente con fines educativos, así que úsalo bajo tu propia responsabilidad y verifica con otras fuentes si es necesario.
✨ Pregunta a Lara — tu compañera de estudio con IA
Desbloquea soporte de aprendizaje personalizado. Lara puede explicar lecciones, resumir temas y responder tus preguntas — disponible desde el plan Go y superiores.
Lara te ayuda a aprender más rápido — exclusivo para los miembros ReadyTools Go, Plus y Max.

