OneCompiler

Python Program

input is xyz

output is xyz
xyZ
xYz
xYZ
Xyz
XyZ
XYz
XYZ

write a python Program?

2 Answers

4 years ago by

s = input()
s_length = int('1'*len(s),2)
for i in range(s_length+1):
i_bin = "{0:b}".format(i)
s_list = list(s.lower())
for j in range(len(i_bin)):
if i_bin[-j-1]=='1':
s_list[-j-1] = s_list[-j-1].upper()
print(''.join(s_list))

4 years ago by Nazar Ravlyk

Using a couple of functions:

s=input(">>> ")
L=len(s.strip())
p=lambda n: format(n,f"0>{L}b")
c=lambda b,d: "".join([x.upper() if int(y) else x for x,y in zip(d,b)])
print("\n".join([c(p(i),s) for i in range(1<<L)])) 
4 years ago by markmoretto