Use a for/else loop to traverse through the key names in the dictionary below in order to find Mr. Potatohead’s mailing address. The key name is his social security number. Once you find his SSN (key-name), you can display its value by using the following function:
print (Dictary.get(123-45-6789))

If the key you are looking for does not exist, your code should break out of the loop and display the following message: “Key not found”

Dictary = {
'code':6734,
'dept': 'sales',
123-45-6789:"Mr.Potato Head \n234 Potato Lane \nPotato Chip, ID 77725"
}

Respuesta :

Dictary = {

'code':6734,

'dept': 'sales',

123-45-6789:"Mr.Potato Head \n234 Potato Lane \nPotato Chip, ID 77725"

}

for i in Dictary.keys():

   if i == 123-45-6789:

       print(Dictary.get(i))

       break

else:

   print("Key not found")

You can further test this code by deleting Mr.Potato head's info from the dictionary. I hope this helps!