#here n is the number of elements to be inserted in list
n=int(input('enter size of list'))
li=[]
print('enter',n,'elements in list')
for i in range(n): #taking n input from user and storing it in list
li.append(input())
li[i]=int(li[i])
max=li[0]
for i in range(n): #findingthe largest element
if(max<li[i]):
max=li[i]
m=li[0]
for i in range(n): #finding the second largest element
if(max!=li[i]):
if(m<li[i]):
m=li[i]
print(m) #printing the second largest element
n=int(input('enter size of list'))
li=[]
print('enter',n,'elements in list')
for i in range(n): #taking n input from user and storing it in list
li.append(input())
li[i]=int(li[i])
max=li[0]
for i in range(n): #findingthe largest element
if(max<li[i]):
max=li[i]
m=li[0]
for i in range(n): #finding the second largest element
if(max!=li[i]):
if(m<li[i]):
m=li[i]
print(m) #printing the second largest element
Comments
Post a Comment