from functools import reduce def func_1(): a, b, *c = [1, True, 4, 6, 'hello ', 7, 9] print(a, b, c) a, *b, c = [1, True, 4, 6, 'hello ', 7, 9] print(a, b, c) *a, b, c = [1, True, 4, 6, 'hello ', 7, 9] print(a, b, c) a, *b, c = 'hello moto' print(a, b, c) a, *b, c = [1, 4] print(a, b, c) def func_2(): a, b, *c = range(5) print(c) *a, b, c = 'No money', 'no honey' print(a, b, c) # *values = [1, 2, 3, 4, 5] # так не сработает *values, = [1, 2, 3, 4, 5] print(values) # def print_values(one, two, three): # print(one, two, three) def print_values(*values): print(values, sep=',') def count_args(*args): return len(args) def multiply(*args): if not args: return 1 return reduce(lambda a, b: a*b, args) def check_sum(*args): return print("not enough") if sum(args) < 50 else print("verification passed") def is_only_one_positive(*args): return len(list(filter(lambda x: x > 0, args))) == 1 def print_goods(*args): counter = 1 for x in args: if isinstance(x, str) and x != "": print(f'{counter}. {x}') counter += 1 if counter == 1: print('Нет товаров') def main(): # func_1() # func_2() # words = 'Hello', 'Aloha', 'Bonjour' # print_values(*words) # print_values(1, 2, 3, 4) # print(count_args(1, 2, 3, 4, 5)) # print(multiply(1, 2, 3, 4, 5)) # print(multiply(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10)) # check_sum(10, 10, 10, 10, 9) # print(is_only_one_positive(-3, -4, -1, 3, 4)) print_goods(1, True, 'Грушечка', '', 'Pineapple') if __name__ == '__main__': main()