ich habe die im Betreff genannte Kombination:
- Python 2.6.6
- list comprehensions
Code: Alles auswählen
from __future__ import print_function
from itertools import product
def allCaseCombosList(string):
l = [(c, c.upper()) if not c.isdigit() else (c,) for c in string.lower()]
return ["".join(item) for item in product(*l)]
choice = []
for x in ['test', 'live']:
for y in allCaseCombosList(x):
if y not in choice:
choice.append(y)
Code: Alles auswählen
from __future__ import print_function
from itertools import product
def allCaseCombosList(string):
l = [(c, c.upper()) if not c.isdigit() else (c,) for c in string.lower()]
return ["".join(item) for item in product(*l)]
choice = set([word for word in allCaseCombosList(element) for element in ['test', 'live']])
Code: Alles auswählen
NameError: name 'element' is not defined