number=[1,2,3,4,5,6,7,8,9,1] print(number.index(1,1)) answer =9 how??

0 votes
asked Oct 10, 2019 by Ehtisham Farrukh

2 Answers

0 votes
answered Oct 12, 2019 by kabir singh
This is because index() having 3 arguments

element , start(opt), end(opt)

In your example :

number.index(1,1)

means position of 1 , start searching from the first position.

therefore answer is 9 position.
0 votes
answered Nov 7, 2019 by dheeraj (1,090 points)
yes,it is printing '9' because 'index' command used for finding the position in the list

index(element,start(),end())

it contain 3 arguments
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...