Lesson 19 of 34
Dictionaries: പേരുകളിൽ നിന്ന് Values
10 min 30 XP
Dictionary ഒരു യഥാർത്ഥ നിഘണ്ടു പോലെ പ്രവർത്തിക്കുന്നു: ഓരോ key-ക്കും ഒരു value. { }-നുള്ളിൽ key: value ജോഡികൾ എഴുതൂ. Values index കൊണ്ടല്ല, key കൊണ്ടാണ് കണ്ടെത്തുന്നത്.
Example: edit me and press Run
Press Run to see the result here.ഇല്ലാത്ത key ചോദിച്ചാൽ error വരും. get() പകരം None അല്ലെങ്കിൽ നിങ്ങൾ തിരഞ്ഞെടുക്കുന്ന default നൽകുന്നു.
Example: edit me and press Run
Press Run to see the result here.Keys-ഉം values-ഉം ഒരുമിച്ച് loop ചെയ്യാൻ items() ഉപയോഗിക്കൂ.
Example: edit me and press Run
Press Run to see the result here.എണ്ണാൻ dictionaries ഉത്തമമാണ്: count[ch] = count.get(ch, 0) + 1. ഇത് interviews-ൽ എപ്പോഴും വരുന്നു!