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

python, string

Solution

import itertools

s = 'Fox'
map(''.join, itertools.product(*zip(s.upper(), s.lower())))
>>> ['FOX', 'FOx', 'FoX', 'Fox', 'fOX', 'fOx', 'foX', 'fox']

Problem

I want to write a program that would take a string, let's say `"Fox"`, then it would display: ``` fox, Fox, fOx, foX, FOx, FoX, fOX, FOX ``` My code so far: ``` string = raw_input("Enter String: ") length = len(string) for i in range(0, length): for j in range(0, length): if i == j: x = string.replace(string[i], string[i].upper()) print x ``` Output so far: ``` Enter String: fox Fox fOx foX >>> ```

Original source

Related problems