Dictionaries

Dictionaries

Dictionaries offer you a way to store data in a key pair way. You can get any assigned value through the key of it. Dictionaries are created using curly brackets{}. Values are assigned to keys using a colon: and different pairs are separated using a comma. They are used in the following way: -

------------------------------------------------------

Code: -

myDict = { "name" : "python" , "level" : "easy" }

print(myDict["name"])

Output: -

python

------------------------------------------------------

One can also add new values using new key names that do not exist in the dictionary or change the value of existing.

------------------------------------------------------

Code: -

myDict = { "name" : "python" , "level" : "easy" }

myDict["level"] = "very easy"

print(myDict["level"])

Output: -

very easy

------------------------------------------------------


Comments

  1. can you help on Django too?

    ReplyDelete
    Replies
    1. Ya sure,
      After python, I am a professional Django expert. Currently working on completing this blog series on python but if you want to learn Django or have any doubt in it you can anytime mail me on sanatjha4@gmail.com

      Delete
  2. These things from my audience pushes me all the way to keep spreading knowledge that I gain everyday.
    Thanks alot...😊😊

    ReplyDelete

Post a Comment

Popular Posts