🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

Python list की index() विधि का क्या उद्देश्य है?

What is the purpose of the index() method in a Python list?

A
किसी item को हटाना (To remove an item)
B
किसी item को जोड़ना (To add an item)
C
किसी item का पहला index ढूँढना (To find the first index of an item)
D
list को sort करना (To sort the list)
Explanation

Python में list.index(item) method का उपयोग list में दिए गए item का पहला index पता करने के लिए किया जाता है।

It returns the index (position) of the first occurrence of the specified value.


🔹 Example / उदाहरण:

fruits = ['apple', 'banana', 'cherry', 'banana']
print(fruits.index('banana'))   # Output: 1

➡ क्योंकि 'banana' सबसे पहले index 1 पर आता है।

Correct Answer: C) किसी item का पहला index ढूँढना (To find the first index of an item)

Latest Updates