WAP in python script to find minimum element along with its index value from a list of elements
Answers
>>>li=list(input("enter list elements"))
enter list elements6,4,9,8,2
>>>li
[6,4,9,8,2]
>>>min(li)
2
>>>li.index(min(li))
4
You may do this program with any list of your choice.
L = list( )
num = int ( input ( "Enter number of elements to be entered : " ) )
i = 0
while ( i < num ) :
item = eval ( input ( " Enter an element : " ) )
L . append ( item )
i = i + 1
print ( " \n List created by you : " , L )
min = L [ j ]
for j in range ( 0 , Len ( L ) ) :
if ( min > L [ j ] ) :
min = L [ j ]
print ( " Minimum number in your list is " , min , " located at the index value of " , j+1 , " th position. " )
OUTPUT
>>> Enter number of elements to be entered : 5
>>> Enter an element : 35
>>> Enter an element : 23
>>> Enter an element : 42
>>> Enter an element : 15
>>> Enter an element : 20
>>>
>>> List created by you : [ 35 , 23 , 42 , 15 , 20 ]
>>> Minimum number in your list is 15 located at the index value of 4 th position.