Python – Access Tuple Items
1. What Does “Access Tuple Items” Mean?
Accessing tuple items means getting values from a tuple.
Tuples are like lists, but:
👉 Tuples cannot be changed.
2. Access Items Using Index
Each item in a tuple has a position number (index).
Important:
-
Index starts from 0
Example
Output:
3. Negative Indexing
Negative index starts from the end.
-
-1→ last item -
-2→ second last item
Example
Output:
4. Access a Range of Items (Slicing)
You can get more than one item using slicing.
Example
Output:
👉 End index is not included.
5. Access From Beginning
Example
Output:
6. Access Till End
Example
Output:
7. Access Items Using Loop
Example
8. Check if Item Exists
Example
9. Tuple Length
Example
10. Common Beginner Mistakes
❌ Index Out of Range
❌ Error.
✔ Fix:
❌ Trying to Change Tuple Item
❌ Error: tuple items cannot be changed.
11. Simple Practice Examples
Example 1: Print First and Last Item
Example 2: Slice Tuple
Example 3: Check Name
12. Summary (Access Tuple Items)
✔ Use index to access items
✔ Index starts from 0
✔ Negative index works
✔ Slicing returns a tuple
✔ Tuples are read-only
📘 Perfect for Beginner eBook
This chapter is ideal for:
-
Python beginner books
-
School & college students
-
Self-learners
If you want next, I can write:
-
Change Tuple Items
-
Add Tuple Items
-
Remove Tuple Items
-
Tuple Exercises
Just tell me 😊
