import json
def combine_and_save_dicts():
# Input paths for dictionaries
dict1_path = input("Enter path for dictionary one: ")
dict2_path = input("Enter path for dictionary two: ")
# Load dictionaries from files
with open(dict1_path, 'r') as file1:
dict1 = json.load(file1)
with open(dict2_path, 'r') as file2:
dict2 = json.load(file2)
# Combine dictionaries
combined_dict = {**dict1, **dict2}
# Save combined dictionary to output.txt
with open('output.txt', 'w') as output_file:
json.dump(combined_dict, output_file, indent=4)
print("Dictionaries combined and saved to output.txt")
# Run the function
combine_and_save_dicts()
def combine_and_save_dicts():
# Input paths for dictionaries
dict1_path = input("Enter path for dictionary one: ")
dict2_path = input("Enter path for dictionary two: ")
# Load dictionaries from files
with open(dict1_path, 'r') as file1:
dict1 = json.load(file1)
with open(dict2_path, 'r') as file2:
dict2 = json.load(file2)
# Combine dictionaries
combined_dict = {**dict1, **dict2}
# Save combined dictionary to output.txt
with open('output.txt', 'w') as output_file:
json.dump(combined_dict, output_file, indent=4)
print("Dictionaries combined and saved to output.txt")
# Run the function
combine_and_save_dicts()