I am looping over many files in folder A and folder B to do some operations on the merged data frame of A_file1 and B_file1; A_file2 and B_file2 etc.
for a in A_list:
for b in B_list:
A_file = pd.read_csv(f'A_file{a}.csv')
B_file = pd.read_csv(f'B_file{b}.csv')
new_file = pd.merge(A_file, B_file, on="common_var", how='left')
new_file.to_csv(f'new_file{a}_{b}.csv')
How do I make the loop continue if either A_file or B_file does not exist for a particular {a} or {b}? (And just not create an {a}_{b} file if either {a} or {b} does not exist?)