within the invoke Python scope. I am just trying to check if each of the variables contains any of the string mentioned in 'a'. If yes then add it as a row to the excel sheet.

import pandas as pd

import xlsxwriter

def excel_data(mz01arg,p028arg,p006arg,s007arg,mz01desc,p028desc,p006desc,s007desc):

listb=[]

a=['MZ01','P028','P006','S007']

if any (x in mz01arg for x in a) is True:

listb[0] = [mz01arg]

else:

listb[0] = []

if any (x in p028arg for x in a ) is True:

listb[1] = [p028arg]

else:

listb[1] =[]

if any (x in p006arg for x in a) is True:

listb[2]=[p006arg]

else:

listb[2] = []

if any (x in s007arg for x in a) is True:

listb[3]=[s007arg]

else:

listb[3]=[]

df1 = pd.DataFrame({'SODA COUNT': listb})

df2 = pd.DataFrame({'SODA RISK DESCRIPTION': [mz01desc,p028desc,p006desc,s007desc]})

writer = pd.ExcelWriter(r"D:\Single_process_python\try_python.xlsx", engine='xlsxwriter')

df3 = pd.concat([df1,df2],axis=1)

df3.to_excel(writer,sheet_name='Sheet1', index=False)

writer.save()