0

Is it more preferable to use the .get method for indexing a dictionary than without it?

Since you would get none instead of an error if the value didn't exist.

12th Aug 2016, 2:58 PM
Andrew
1 Odpowiedź
+ 1
Short answer, yes. Actually, it is only preferred if you have changing dictionaries and you are not sure if the keys exist. It saves you the time to add extra code for possible errors related to missing keys.
27th Aug 2016, 5:59 PM
Eduard Hirsch
Eduard Hirsch - avatar