Let's say I have a dictionary like this:
phone_numbers = {'Ted': '555-222-1234', 'Sally': '555-867-5309'}
I'd like function that returns both the key and the value passed to it, e.g.:
>>> phonebook(phone_number['Ted'])
Ted's phone number is: 555-222-1234
In pseudocode, the function would be:
def phonebook(number):
print("{}'s phone number is: {}".format(
number.key(), # Not a real dictionary method!
number.value()) # Also not a real dictionary method!
Is there a way to do this without a lot of major back-end rewriting of types and classes?