martedì 12 marzo 2024

Easy way to manage dictionaries in Python

#given a dictionary key-value, increments the amount by value. def inc_dict_value(self, dict, key, value): if key not in dict: dict[key] = value else: dict[key] += value

Nessun commento: