Python Dictionaries
dict={ key : value }
for eg:- dict={ "name" : "EDUshark", "marks" : 100 }
here name and marks enclosed within inverted commas are acting as key whereas edushark and 100 are their values. That combine together and make key : value pair.
A dictionaries operation that takes a key and finds the corresponding value is called LOOK UP.
Another way to create dictionaries,
dict = { "name" : [ 'harry','sha','hp' ], "marks" : [ 55,32,15 ] }
suppose you want to add "EDUshark" inplace of "sha".
then, write dict[ 'sha' ] = "EDUshark"
YOU can add dictionaries in loop, conditional statements, or while working with mysql-connector, etc...
Comments
Post a Comment