[Solved] Why fuction’s not returning value? [closed]


Your update2new function definitely returns something:

def update2new(src_dest):

    print("Hi")
    fileProcess(src_dest)
    os.remove('outfile.csv')
    os.remove('new.csv')

    return src_dest

But you don’t capture it in your main:

def main():
    print("<------Initializing Updating Process------>")
    srcFile="abc_20160301_(file1).csv"
    update2new(srcFile) #the return is NOT captured here
    print('\nSuccessfully Executed [ {}]......'.format(str(srcFile)),end='\n')
    print ("OK")

Change it to:

def main():
    print("<------Initializing Updating Process------>")
    srcFile="abc_20160301_(file1).csv"
    srcFile = update2new(srcFile) #get the return here
    print('\nSuccessfully Executed [ {}]......'.format(str(srcFile)),end='\n') #then your printing should be OK
    print ("OK")

4

solved Why fuction’s not returning value? [closed]