Hi,
I am trying to calculate the largest and 2nd largest values in Python. Following is my code:
def find_largest_and_second_Largest(list1):
maxV = max(list1[0], list1[1])
max2V = min(list1[0], list1[1])
for i in range (2, len(list1)):
if (maxV > list1[i]):
if (max2V > list1[i]):
continue
else:
max2V = list1[i]
else:
maxV= list1[i]
max2V = maxV
print("Largest ="+ str(max))
print("2nd Largest =" + str(max2V))
The output is:
Largest =
2nd Largest =34
Somebody please guide me.
Zulfi.