It's impossible to have with your code duplicates, because you're not creating duplicates.
I changed your code a litte bit (functionality is the same):
I changed your code a litte bit (functionality is the same):
from pprint import pprint src_base_path = "/data/infy" year_mth = "2020-10-05" folder_names = ["1", "2", "3"] table_names = ["bt1", "bt2", "bt3"] print(f"Tables to be processed: {table_names}") print(f"Folders to be processed: {folder_names}") src_path = "{0}/{1}/app_date={2}/source={3}/" input_body = [] for folder_name in folder_names: for table_name in table_names: input_body.append( { "sourcePath": src_path.format( src_base_path, table_name, year_mth, folder_name ), "tableName": table_name, } ) pprint(input_body)A dict can have only unique keys. Putting stuff into a dict with the same key will overwrite the old value.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!