Accessing List Elements :-
Python में Accessing List Elements का अर्थ है List में मौजूद किसी particular element (value) को प्राप्त करना या उसे program में use करना। List के elements को मुख्य रूप से उनके Index Number की सहायता से access किया जाता है।
List में indexing 0 से शुरू होती है।
English
Accessing List Elements means retrieving or using a particular element (value) from a list. List elements are mainly accessed using their index numbers.
Python uses zero-based indexing, so the first element has index 0.
Example:-
numbers = [10, 20, 30, 40, 50]
print(numbers[0])
print(numbers[2])
Output:-
10
30
Because:-
यहाँ List के elements और उनके indexes हैं:
Element : 10 20 30 40 50
Index : 0 1 2 3 4
numbers[0] → 10
numbers[1] → 20
numbers[2] → 30
numbers[3] → 40
numbers[4] → 50
Important Point :-
यदि List में मौजूद index से बाहर का index access किया जाता है, तो Python IndexError देता है।
numbers = [10, 20, 30]
print(numbers[5])
यहाँ 5 index मौजूद नहीं है, इसलिए IndexError: list index out of range आएगा।