I want this result but not by string ,by input() and Number of characters unknown!
mystring = 'abcd'
for a in (mystring[0].upper(), mystring[0].lower()):
for b in (mystring[1].upper(), mystring[1].lower()):
for c in (mystring[2].upper(), mystring[2].lower()):
for d in (mystring[3].upper(), mystring[3].lower()):
print(a+b+c+d)
One approach using swapcase
and itertools.permutation:
from itertools import product
mystring = 'abcd'
cases = zip(*[mystring, mystring.swapcase()])
for permutation in product(*cases):
print("".join(permutation))
Output
abcd
abcD
abCd
abCD
aBcd
aBcD
aBCd
aBCD
Abcd
AbcD
AbCd
AbCD
ABcd
ABcD
ABCd
ABCD