i want to pass string (dirPath + dirName[x]) to a function
i already tried 3 times to combining string and a specific list (only dirName[x])
it seems that python just rejecting it anyway even if i already convert it to another type.
is anyone know how i pass this string to Function?
layer = 0
dirName = []
#dummy value layer = 4, dirName = [/a,/b,/c,/d], dirBruteForce(layer,vault)
def dirBruteForce(layer,dirPath):
if layer > 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
###
try1:
dirBruteForce(layer - 1, dirPath + dirName[x])
TypeError: can only concatenate list (not "str") to list
try2:
list = [dirPath,str(dirName[x])]
dir = ''.join(list)
dirBruteForce(layer - 1, dir)
error2:
dir = ''.join(list)
TypeError: sequence item 0: expected str instance, list found
try3:
dir = ''.join([dirPath,dirName[x]])
dirBruteForce(layer - 1, dir)
error3:
dir = '-'.join([dirPath,dirName[x]])
TypeError: sequence item 0: expected str instance, list found
Copyright Notice:Content Author:「Ilyasofficial」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46158628/python-passing-string-and-specific-lists-combined-into-function