Answers for "how to store the variable in dictionary"

0

how to store the variable in dictionary

>>> mydict = {'a': 'hello', 'b': 'world'}
>>> for x in mydict:
...    val = mydict[x]
...    mydict[x] = val.upper()
...    print('Changed what', x, 'points to: from', val, 'to', mydict[x])
Changed what b points to: from world to WORLD
Changed what a points to: from hello to HELLO
Posted by: Guest on April-25-2020
0

how to store the variable in dictionary

>>> mydict = {"message": {"hello": 123456}}
>>> print(mydict['message'])
{'hello': 123456}
>>> print(mydict['message']['hello'])
123456
Posted by: Guest on April-25-2020

Code answers related to "how to store the variable in dictionary"

Python Answers by Framework

Browse Popular Code Answers by Language