Report Bug
Qus :

What will be the output of the following Python code?

myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
    if myList[i] > max:
        max = myList[i]
        indexOfMax = i   
print(indexOfMax)

Qus

निम्नलिखित Python कोड का आउटपुट क्या होगा?

myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
    if myList[i] > max:
        max = myList[i]
        indexOfMax = i   
print(indexOfMax)


A. 1
B. 2
C. 3
D. 4


Solution
A. 1



Explanation
First time the highest number is encountered is at index 1.



Report Bug