Q. Write a function that returns the largest element of the list passed as parameter.
Answer :-
def large( lst ) : large = lst [ 0 ] for i in lst : if large < i : large = i return large lst = eval(input("Enter a list :-")) print( "Largest Number :-", large(lst) )
Alternate Method or Short Method
def large( lst ) : lst.sort() return lst [ -1 ] lst = eval(input("Enter a list :-")) print( "Largest Number :-", large(lst) )
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )