There is a dictionary, where the key is the value that we later enter through Input, and the value of the dictionary is the name of the function. Separately, each function is performed for the list (it is generated randomly.) How to make that several functions are performed at the same time, which we enter via Input and then look for it in the dictionary?
Code snippet:
functions = {'sum': sum_list, 'multiply': multiply_list, 'join': join_list, 'union': union_list, 'reverse': reverse_list, 'negated': negated_list, 'inverted': inverted_list, 'squared': squared_list, 'odds': odds_list, 'evens': evens_list, 'simples': primenumbers_list} name = input("Выберите 'sum', 'multiply', 'join', 'union', 'reverse','negated' " "'inverted', 'squared','odds', 'evens', 'simples': ") reducer = functions[name] result = reduce(reducer, randlist) print(result)