I need to work with different folder paths so I wrote this function to create them. Unfortunately I am not able to call the result vector. It always gives me a "None". By uncommenting the "#" I can see that the function works perfectly fine. I guess my mistakes lies somewhere in the last two lines, but that is what I found searching for how to store the result of a function.
Any ideas what I am doing wrong? Is there anything special to consider when saving the output of a function that is supposed to return a vector with multiple strings?
I'm using Python IDLE version 2.6.5 if that helps...
Thank you in advance for your help!
>>> def path_generator(path1,path2,path3):
#res = []
for i in path1:
first_string = i
for j in path2:
second_string = first_string+"\\"+j
for k in path3:
end_string = second_string+"\\"+k
#res.append(end_string)
#print res
del i,j,k,first_string,second_string
>>> origin = ["C:\\one","C:\\two"]
>>> subfolders = ["subfolder1","subfolder2","subfolder3","subfolder4"]
>>> files = ["testfile1.txt","testfile2.txt","testfile3.txt","testfile4.txt"]
>>> result = path_generator(origin,subfolders,files)
>>> print result
None
in order for your function to return anything you need to tell it to, i am assuming you want to return the list res
so add the line return res
to the bottom of your function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.