# -*- coding:utf-8 -*- # à la base j'ai lu un truc sur le net, '5..5..5..5 = 30' .. # je trouvais pas alors j'ai voulu tester toutes les possibilités # donc comme il y a 3 signes variables dans 5.5.5.5, je me suis dit \ # je vais faire 3 loops for # # mais comment je peux faire ça d'une manière propre qui marcherait \ # avec n'importe quel nombre de variables ? signes = '/ * - +'.split() phr = '5.5.5.5' a = [] for i in range(phr.count('.')): a.append(0) i = len(a)-1 for z in range(len(signes)**len(a)): for v in a: print signes[v], print while a[i] == len(signes)-1: a[i] = 0 i -= 1 a[i] += 1 i = len(a)-1