I am trying for some time now to imagine a way to generate all possible capitalizations of a word in Python. For instance:
hello
Hello
HEllo
...
heLLo
...
HeLlO
I found some built-in functions which work on capitalization (.capitalize()
for instance) but they seem to address typical cases (simple sentences, bibliography). I would be grateful for a hint on where to look as the for
loops I thought of, as well as recursion were not a solution (I will not mention them here, they were so wrong)
Clarification: since between 5 and 9 people (via a put on hold, downvote and comments) need a clarification, I will try to make one, using different words.
I have a string made up of characters from a to z (called later word). I would like, in Python, to get a list of the said word, but capitalized in all possible ways (that is, a mixture of upper case letters (like
M
) and lower case ones (likef
). This leads to a list similar to the one above (with variations of the wordhello
.
I am sure glad I did not ask how to multiply two numbers, I would have need to clarify with a crash course in algebraic rings.