How to format dictionary with pprint library?
How to format dictionary? Question: I have this function: def total_fruit_per_sort(): number_found = re.findall(total_amount_fruit_regex(), verdi50) fruit_dict = {} for n, f in number_found: fruit_dict[f] = fruit_dict.get(f, 0) + int(n) return pprint.pprint(str( {value: key for value, key in fruit_dict.items() }).replace("{", "").replace("}", "").replace("’", "")) print(total_fruit_per_sort()) But it prints the values like: ‘Watermeloenen: 466, Appels: 688, Sinaasappels: 803’ …