Question · Python course · Module 2: Data Structures
The get() Method
What is the advantage of dict.get('key') over dict['key']?
Answer options
- It is faster
- It returns None instead of an error when the key doesn't exist
- It automatically sorts the dictionary
- There is no difference
Show the answer
Correct answer:
- It returns None instead of an error when the key doesn't exist