if __name__ == '__main__':
print '======= Possible combinations for the math question ============'
for first, last in my_list:
lst = list(init_lst)
lst.remove(first)
lst.remove(last)
for exp in [first + ''.join(f) + last for f in itertools.permutations(lst)]:
if any([y in exp for y in BAD_LIST]) or
re.search(r'[-*/+][-*/+]+|^(.*)$', exp): continue
elif exp not in exp_list:
try:
print "%s = %d" % (exp, eval(exp))
exp_list.append(exp)
except: pass
print 'Total expressions found = ', len(exp_list)