for n1 inrange(len(numbers)): for n2 inrange(len(numbers)): for n3 inrange(len(numbers)): for n4 inrange(len(numbers)): for o1 inrange(len(operators)): for o2 inrange(len(operators)): for o3 inrange(len(operators)): if (n1 == n2 or n1 == n3 or n1 == n4 or n2 == n3 or n2 == n4 or n3 == n4) or (o1 == o2 or o2 == o3 or o1 == o3): continue string = f"((({numbers[n1]}{operators[o1]}{numbers[n2]}){operators[o2]}{numbers[n3]}){operators[o3]}{numbers[n4]})" ifeval(string) == 1024: ok.append(string)
for n1 inrange(len(numbers)): for n2 inrange(len(numbers)): for n3 inrange(len(numbers)): for n4 inrange(len(numbers)): for o1 inrange(len(operators)): for o2 inrange(len(operators)): for o3 inrange(len(operators)): if (n1 == n2 or n1 == n3 or n1 == n4 or n2 == n3 or n2 == n4 or n3 == n4) or (o1 == o2 or o2 == o3 or o1 == o3): continue string = f"((({numbers[n1]}{operators[o1]}{numbers[n2]}){operators[o2]}{numbers[n3]}){operators[o3]}{numbers[n4]})" try: ifeval(string) == 1024: ok.append(string) except: pass