chiffres = [1,2,3,4,5,6,9] for a in chiffres: for b in chiffres: for c in chiffres: if (a - b) * (a - c) * (b - c) != 0: p = str(8 * (100 * a + 10 * b + c)) abc = str(a) + str(b) + str(c) if p[0] == '7' and len(p + abc) == len(set(p + abc)): if all([int(c) in chiffres for c in p[1:]]): print('{}{}{}*8={}'.format(a,b,c,p))