with open('Input.txt') as file_object:
contents = file_object.readlines()
if '\n' in contents:
contents.remove('\n')
print(contents)
string_to_convert = contents[0]
list_from_string = [i for i in string_to_convert]
print(list_from_string)
output_dict = {}
for letter in list_from_string:
if letter in output_dict:
output_dict[letter] += 1
else:
output_dict[letter] = 1
del output_dict['\n']
print(output_dict)
result_string = ""
for key, value in output_dict.items():
result_string += str(key) + str(value)
print(result_string)
with open("output.txt", "w", encoding="utf-8") as f:
f.write(result_string)