accessing dictionary elements in python accessing dictionary elements in python python dictionary accessing an element

The solution for “accessing dictionary elements in python accessing dictionary elements in python python dictionary accessing an element” can be found here. The following code will assist you in solving the problem.

thisdict = {
“brand”: “Ford”,
“model”: “Mustang”,
“year”: 1964
}
x = thisdict[“model”]>>> mydict[“Apple”]
{‘American’: ’16’, ‘Mexican’: 10, ‘Chinese’: 5}

IN PYTHON
unlike javascript don’t use . operator to create/assign dic. keys to value
use dic[key] syntax not dic.key(like java script)

NOTE:
in pythyon oops we only use . operator to access methods and attributes
and to even access using reference variable like head in linkedlist

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in