Python – Access List Items
1. What Does βAccess List Itemsβ Mean?
Accessing list items means getting values from a list.
In simple words:
π It means reading items from the list.
2. List Index (Position)
Each item in a list has a position number called index.
Important rules:
-
Index starts from 0
-
First item β index
0 -
Second item β index
1
Example
Output:
3. Access Item Using Index
Example
Output:
4. Negative Indexing
Negative index means counting from the end of the list.
-
-1β last item -
-2β second last item
Example
Output:
5. Access a Range of Items (Slicing)
Slicing means getting more than one item.
Example
Output:
π End index is not included.
6. Access From Beginning
Example
Output:
7. Access Till End
Example
Output:
8. Check if Item Exists
Example
9. Access Items Using Loop
Example
10. Common Beginner Mistakes
β Index Out of Range
β Fix:
β Wrong Index Expectation
β Correct:
11. Simple Practice Examples
Example 1: Print First and Last Item
Example 2: Slice List
Example 3: Check Name
12. Summary (Access List Items)
β Use index to access items
β Index starts from 0
β Negative index counts from end
β Slicing gives multiple items
β in checks item existence
π 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 List Items
-
Add List Items
-
Remove List Items
-
List Methods
-
List Exercises
Just tell me π
