python - Find all upper, lower and mixed case combinations of a string -


i want write program take string, let's "fox", display:

fox, fox, fox, fox, fox, fox, fox, fox 

my code far:

string = raw_input("enter string: ") length = len(string) in range(0, length):     j in range(0, length):         if == j:             x = string.replace(string[i], string[i].upper())             print x 

output far:

enter string: fox fox fox fox >>>  

>>> import itertools >>> map(''.join, itertools.product(*((c.upper(), c.lower()) c in 'fox'))) ['fox', 'fox', 'fox', 'fox', 'fox', 'fox', 'fox', 'fox'] 

or

>>> s = 'fox' >>> map(''.join, itertools.product(*zip(s.upper(), s.lower()))) 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -