# reverse phonebook program
# look up a number, find a name.

# The original phonebook is a dictionary
phonebook = {}
phonebook["Bob"] = 7584029
phonebook["Lucy"] = 2206830
phonebook["Morris"] = 6730056

# We'll fake the reverse phonebook using a list
listlen = 7
poser = [0]*7 # originally filled with zeros
for name in phonebook:
    number = phonebook[name]
    index = number % listlen # compute remainder
    # use remainder as index telling you where to store
    # the number, name pair tuple
    poser[index] = (number,name)

# Ends up as a list of either zeros or tuples
print(poser)

numStr = input("Enter a phone number: ")
number = int(numStr) # should have checked to see if
# the string can be converted to integer
index = number % listlen
# compute index where that number would be if it was in
# my fake dictionary

if poser[index] == 0:
    # item was not in dictionary
    print("I don't have that number")
else:
    dataTuple = poser[index] # get the tuple 
    if dataTuple[0] == number:
        print("This is the number of",dataTuple[1])
    else:
        # wrong number - the phone number does not
        # match the one in the tuple
        print("Wrong number")
    

