How to convert dictionary keys and values to strings in Python

1 Answer

0 votes
dictionary = {1: 300, 2: 4000, 3: 88}

dictionary_str = {str(k): str(v) for k, v in dictionary.items()}

print(dictionary_str)



'''
run:

{'1': '300', '2': '4000', '3': '88'}

'''

 



answered Feb 27 by avibootz
...