from functools import reduce def append_to_list_1(value, my_list = []): my_list.append(value) print(my_list, id(my_list)) return my_list def test_1(): lst = append_to_list_1(10) lst = append_to_list_1(25) lst = append_to_list_1(37) print('Итог', lst, id(lst)) def append_to_list_2(value, my_list=None): if my_list is None: my_list = [] my_list.append(value) print(my_list, id(my_list)) return my_list def test_2(): result1 = append_to_list_2(10) result1 = append_to_list_2(15, result1) result2 = append_to_list_2(25) result2 = append_to_list_2(37, result2) # Словарь def append_to_dict(key, value, my_dict=None): if my_dict is None: my_dict = {} my_dict[key] = value return my_dict def replace(text, old, new=''): ret = '' for i in range(len(text)): if text[i] == old: ret += new else: ret += text[i] return ret def product(lst: list, start=1): return reduce(lambda a, b: a*b, lst, start) def main(): # test_1() # test_2() # print(replace('nobody; i myself farewell analysis', 'l', 'z')) print(product([1, 2, 3], start=10)) if __name__ == '__main__': main()