title: How to implement a recursive version of this program?
body: <p>I'd like some help, perhaps some pointers to how to think about the solution to the following recursively.</p>
  <p>The program is supposed to take a sentence and print all different ways we could emphasize the words in this sentence.</p>
  <p>Something like this:</p>
  <pre><code>Input: 
  
  what are you doing
  </code></pre>
  <pre><code>Output:
   
  what are you doing?
  what are you DOING?
  what are YOU doing?
  what are YOU DOING?
  what ARE you doing?
  what ARE you DOING?
  what ARE YOU doing?
  what ARE YOU DOING?
  WHAT are you doing?
  WHAT are you DOING?
  WHAT are YOU doing?
  WHAT are YOU DOING?
  WHAT ARE you doing?
  WHAT ARE you DOING?
  WHAT ARE YOU doing?
  WHAT ARE YOU DOING?
  </code></pre>
  <p>My iterative implementation:</p>
  <pre><code>from itertools import chain, combinations
  
  
  inputStr = &quot;what are you doing&quot;
  wordList = inputStr.split()
  
  
  # getting all possible subsets which are all possible word combinations from inputStr
  def powerset(iterable):
      &quot;powerset([1,2,3]) --&gt; () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)&quot;
     
      a = chain.from_iterable(combinations(iterable, r) for r in range(len(iterable)+1))
      return a
  
  # list of tuples of subsets
  temp = list(powerset(wordList))
  
  # function that converts tuple to string
  def join_tuple_string(strings_tuple) -&gt; str:
     return ' '.join(strings_tuple)
  
  # joining all the tuples into strings
  result = map(join_tuple_string, temp)
  listOfListsOfSubsets = list(result)
  
  #  getting list of lists of words that form all possible subsets of inputStr and converting them to uppercase
  for i in range(0,len(listOfListsOfSubsets)):
      listOfListsOfSubsets[i] = listOfListsOfSubsets[i].split()
  # print(listOfListsOfSubsets)
  
  # converting every word in in every possible subset of words from inputStr into upper-case
  for i in range(0, len(listOfListsOfSubsets)):
      listOfListsOfSubsets[i] = [x.upper() for x in listOfListsOfSubsets[i]]
  
  
  
  # reconstructing each subset of words to the full sentence (matching inputStr) while being case sensitive so that what was converted
  # previously to uppper case, stays upper-case
  for li in listOfListsOfSubsets:
      for word in wordList:
          if word.upper() not in li:
              i = wordList.index(word)
              li.insert(i, word)
      
      # printing all possible allEmphasesOf inputStr
      print(&quot; &quot;.join(li))
  </code></pre>