title: Python creating permutations between one item and list
body: <p>I'm looking to create a list of permutations between one item and a list in Python. For example:</p>
  
  <pre><code>[nyc]
  
  [strawberry, apple, banana, orange, pineapple, ..]
  </code></pre>
  
  <p>I'm trying to get up to four words with 'nyc' always included. The order is important and 'nyc' must always be included. For example:</p>
  
  <pre><code>nyc
  strawberry-nyc
  nyc-strawberry 
  strawberry-apple-nyc
  strawberry-apple-banana-nyc
  </code></pre>
  
  <p>What I've done so far is put all the words into one list, include a few blanks, then create all permutations using itertools, then remove all the lines that don't conatain "nyc" :</p>
  
  <pre><code>import itertools
  import re
  
  # include blanks to allow for four-word permutations to have just one, two, or three words
  adjectives =  ['', '', '', 'nyc', 'strawberry', 'apple', 'banana', 'orange', 'pineapple']
  names = ['-'.join(x) for x in itertools.permutations(adjectives, 4)]
  
  # limit to permutations that contain 'nyc'
  names = [x for x in names if 'nyc' in x]
  
  # since joining blanks using "-", remove the multiple dashes when this happens
  # and also remove leading or trailing dashes
  names = [re.sub(r"-+", "-", x) for x in names]
  names = [re.sub(r"-+$", "", x) for x in names]
  names = [re.sub(r"^-+", "", x) for x in names]
  
  # remove duplicates, since blank can be added multiple times, sort for visual clarity
  names = sorted(list(set(names)))
  
  print(names)
  </code></pre>
  
  <p>I've been looking through itertools and some of the questions here, think I must be overlooking a simple solution. What would be a more effective way to do this?</p>