Find Max


4. Write a Python program to get the smallest number from a list.

# max_num_in_list([1, 2, -8, 0])

#Solution:

def max_num_in_list( list ):
    max = list[0]
    for a in list:
        if a>max:
            max = a
    return max
print(max_num_in_list([1, 2, -8, 0]))



No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...