I want to write a program that would take a string, let's say "abc", then it would display:
abc, Abc, ABc, ABC, AbC, aBc, aBC, AbC
After digging for a while I found this question which solves my problem however, if the string contains some special chars such as @
and .
, it will give me some duplicates in the output , how can I make it so only alphabetic characters are upper/lower? for example if the input is a@c
the output should only be:
A@c
a@C
A@C
a@c
Here is the code I am using:
import itertools
string = 'abc12@abc.com'
x = map(''.join, itertools.product(*((c.upper(), c.lower()) for c in string)))
print(x)