Programming Examples

Python program to display the maximum elements from the two list along with its index in its list


write a program to input two lists and display the maximum elements from the elements of both the list combined, along with its index in its list.

Solution

lst1=eval(input("Enter List 1"))
lst2=eval(input("Enter List 2"))
mx1=max(lst1)
mx2=max(lst2)
if mx1>=mx2:
    print(mx1,"the maximum value in is in the list 1 at index ",lst1.index(mx1))
else:
    print(mx2,"the maximum value in is in the list 2 at index ",lst2.index(mx2
                                                                           ))
Output

Enter List 1[4,5,6,2,3]

Enter List 2[8,3,4,2]

8 the maximum value in is in the list 2 at index  0

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad