title: Python - passing string and specific lists, combined into function
body: <p>i want to pass string (dirPath + dirName[x]) to a function</p>
  
  <p>i already tried 3 times to combining string and a specific list (only dirName[x])</p>
  
  <p>it seems that python just rejecting it anyway even if i already convert it to another type.</p>
  
  <p>is anyone know how i pass this string to Function?</p>
  
  <pre><code>layer = 0
  dirName = []
  #dummy value layer = 4,  dirName = [/a,/b,/c,/d], dirBruteForce(layer,vault)
  
  def dirBruteForce(layer,dirPath):
  if layer &gt; 0 :
      #call again to make layered dir
      for x in range(len(dirName)):
          dirBruteForce(layer - 1, dirPath + dirName[x]) ##this line
  #call end of the dir
  elif layer is 0 :
      for x in range(len(dirName)):
          try:
              os.makedirs(dirPath)
              print(dirPath)
          except Exception as e:
              pass
  ###
  </code></pre>
  
  <p>try1:</p>
  
  <pre><code>dirBruteForce(layer - 1, dirPath + dirName[x])
  TypeError: can only concatenate list (not "str") to list
  </code></pre>
  
  <p>try2:</p>
  
  <pre><code>list = [dirPath,str(dirName[x])]
  dir = ''.join(list)
  dirBruteForce(layer - 1, dir)
  </code></pre>
  
  <p>error2:</p>
  
  <pre><code>dir = ''.join(list)
  TypeError: sequence item 0: expected str instance, list found
  </code></pre>
  
  <p>try3:</p>
  
  <pre><code>dir = ''.join([dirPath,dirName[x]])
  dirBruteForce(layer - 1, dir)
  </code></pre>
  
  <p>error3:</p>
  
  <pre><code>dir = '-'.join([dirPath,dirName[x]])
  TypeError: sequence item 0: expected str instance, list found
  </code></pre>