Python Forum
How to append one function1 results to function2 results
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to append one function1 results to function2 results
#1
Hi, I have two functions and I want to append the results of function1 and function2.

#import difflib
import os
my_dir = 'D:\Backupdata\PythonCodes'
post_fix1 = ['\InputFiles\InputCSV1.csv','\InputFiles\InputCSV2.csv']
post_fix2 = ['\InputFiles\InputCSV1.csv','\InputFiles\InputCSV23.csv']

def myfun1(my_dir,post_fix1):
    result = ''
    for i in range (len(post_fix1)):
        #result = ''
        try:
            full_file = my_dir + str(post_fix1[i])
            #print(full_file)
            if (os.path.exists(full_file)) == True:
                print("File_existpostfix1")
                result = result + '0' + ','
                #print('file exist form postfix1')
            else:
                print('file does not exists')
                result = result + '1' +','
        except FileNotFoundError:
            result = result + '-1' + ','
            print('abormal')
    result = result.strip(',')
    print(result)
def my_fun2(my_dir,post_fix2):
    result1 = ''
    for i in range (len(post_fix1)):
        try:
            full_file = my_dir + str(post_fix2[i])
            if (os.path.exists(full_file)) == True:
                result1 = result1 + '0' + ','
                #print(full_file)
                print("File_existpostfix1",full_file)
            else:
                print('file does not exists2:', full_file)
                result1 = result1 + '1' + ','
        except FileNotFoundError:
            print('abormal2')
            result1 = result1 + '-1' + ','
    result1 = result1.strip(',')
    print(result1)
    
        
myfun1(my_dir,post_fix1)
my_fun2(my_dir,post_fix2)
#final_result = result1.append(result)
#
function1 results =[0,0]
function2 result = [0,1]
I want to final result = [0,0
0,1]
Reply


Messages In This Thread
How to append one function1 results to function2 results - by SriRajesh - Jan-01-2020, 04:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling methods and getting results out HerrAyas 4 410 Apr-02-2024, 09:37 PM
Last Post: deanhystad
  sort search results by similarity of characters jacksfrustration 5 538 Feb-16-2024, 11:59 PM
Last Post: deanhystad
  plotting based on the results of mathematical formulas Timur 1 403 Feb-08-2024, 07:22 PM
Last Post: Gribouillis
  Updating sharepoint excel file odd results cubangt 1 961 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 885 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  Code works but doesn't give the right results colin_dent 2 797 Jun-22-2023, 06:04 PM
Last Post: jefsummers
Bug New to coding, Using the zip() function to create Diret and getting weird results Shagamatula 6 1,561 Apr-09-2023, 02:35 PM
Last Post: Shagamatula
  Trying to send file to printer with no results. chob_thomas 2 3,502 Dec-21-2022, 07:12 AM
Last Post: Pedroski55
  How do I scrape profile information from Twitter People search results? asdad 0 786 Nov-29-2022, 10:25 AM
Last Post: asdad
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,500 Sep-27-2022, 01:38 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020