I'm trying to write the key value pairs of the dictionary to a output file without any commas or square brackets.[I have the values as a list.] How can I remove the commas in between the values?
I tried using map()
and .join()
, but still getting it as:
key1: value1, value2, value3
key2: value1, value2, value3
for keys, values in item_list.items():
outfile.write("{}: {}\n".format(keys, "".join(map(str, str(values)[1:-1]))))
I expect to be written as,
key1: value1 value2 value3
key2: value1 value2 value3