Good night, please tell me how to display only the latest values? I anticipate that the answer is on the surface, but I can not find it .. The fact is that this is only a hundredth part of the entire array and you need to cut off all unnecessary.
a = ['aa', '1', '2', '1.5', '3', '2.1', '0.52', 'ab', '3', '4'] def summ(list): list = float(list) item_list.append(list) length = len(item_list) s = sum(item_list) k = s/length mi = min(item_list) ma = max(item_list) return mi, ma, k for elements in a: if elements.startswith('a'): print('name', elements) item_list = [] else: print(summ(elements)) The following is displayed:
name aa (1.0, 1.0, 1.0) (1.0, 2.0, 1.5) (1.0, 2.0, 1.5) (1.0, 3.0, 1.875) (1.0, 3.0, 1.92) (0.52, 3.0, 1.6866666666666665) name ab (3.0, 3.0, 3.0) (3.0, 4.0, 3.5) it is necessary that only the last entry be output, i.e.
name aa (0.52, 3.0, 1.6866666666666665) name ab (3.0, 4.0, 3.5)