def print_square_list(list_to_square): '''prints out each element of the list squared''' for current_num in list_to_square: print(current_num ** 2) def print_negative_items(some_list): '''print only the negative elements of some_list''' for num in some_list: if num < 0: print(num) def sum_positive(some_list): '''returns the sum of the positive elements of some_list''' sum_so_far = 0 for num in some_list: if num > 0: sum_so_far += num return sum_so_far def get_negative_items(some_list): '''return a list of all the negative elements of some_list''' negative_list = [] # negative items so far for num in some_list: if num < 0: negative_list.append(num) return negative_list def extract_uppercase(string): '''returns a new string of just the uppercase letters of string''' upper = '' for char in string: if char.isupper(): upper += char return upper def list_max(some_list): '''returns the maximum value of some_list''' best_so_far = some_list[0] for num in some_list: if num > best_so_far: best_so_far = num print("best answer is ", best_so_far) return best_so_far def list_length(some_list): '''return the length of some_list''' num_elements = 0 for current_num in some_list: num_elements += 1 return num_elements