## ## Exercise: ## ## Define a function that takes a list of numbers and returns the ## smallest one. If the list is empty, the function should return ## None. ## def find_min (l): if l == []: return None else: smallest = l[0] for element in l: if element < smallest: smallest = element return smallest ## To test: print "[]", find_min([]) print "[1, 2, 3, 4, 5]", find_min([1, 2, 3, 4, 5]) print "[10, 12, 31, 4, 50]", find_min([10, 12, 31, 4, 50])