QuestionQ168

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

Assuming the phone_dir dictionary stores name:number pairs, arrange the code boxes to form a valid line that retrieves Martin Eden’s phone number and assigns it to the number variable.

Drag & Drop
  
Explanation

Python retrieves a dictionary value with the dictionary name followed by the key in square brackets. Therefore, phone_dir["Martin Eden"] returns Martin Eden’s number, and number = assigns that value to the variable.

Community Discussion

No comments yet. Be the first to start the discussion!