Can you try the following:
req_keys = ['col1', 'col2', 'col3', 'col4']
all_list = [incoming[i] for i in req_keys]
all_list = [i for i in all_list if i]
print('1'.join(all_list))
Example:
incoming = {}
incoming['col1'] = 'a'
incoming['col2'] = None
incoming['col3'] = 'c'
incoming['col4'] = None
Output:
a1c
Another Example:
incoming = {}
incoming['col1'] = 'a'
incoming['col2'] = None
incoming['col3'] = None
incoming['col4'] = 'd'
Output:
a1d
solved How to avoid ‘1’ when incoming is none