Answers for "python dict create key"

7

append dictionary python

>>> d1 = {1: 1, 2: 2}
>>> d2 = {2: 'ha!', 3: 3}
>>> d1.update(d2)
>>> d1
{1: 1, 2: 'ha!', 3: 3}
Posted by: Guest on May-21-2020
0

how to make a new key in a dictionary python

a = {"Hello":1}
a["Bye"] = 2
print(a)
# {'Hello':1,'Bye':2}
Posted by: Guest on August-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language