python_math_stat/practica/stepik/stepik_tasks/update_dictionary.py

14 lines
272 B
Python
Raw Normal View History

2023-11-22 17:56:46 +03:00
# function of update dict d
d = {}
def update_dictionary(d,key,value):
if key not in d:
new_key = int(key) *2
if new_key not in d:
d[new_key] = [value]
else:
d[new_key] += [value]
else:
d[key] += [value]