# Arup Guha
# 6/21/2022
# Program to help you learn your state capitals.

def main():

    # Open the file with the state capitals.
    file = open("statecapitals.txt", "r")

    # Dictionary.
    capitals = {}

    # Get first line.
    line = file.readline()

    # Keep going as long as there is data.
    while line:

        # Extract State and Capital.
        toks = line.split("-")
        state = toks[0].strip()
        cap = toks[1].strip()

        # Update my dictionary.
        capitals[state] = cap

        # Get next line.
        line = file.readline()

    # Close the file.
    file.close()

    # Let user ask about capitals.
    while True:

        ans = input("Do you want to ask about a state capital?\n")

        # Stop the program.
        if ans.lower() == "no" or ans.lower() == "n":
            break

        # Get state.
        state = input("What state do you want to know the capital of?\n")

        if state in capitals:
            print("The capital of", state,"is",capitals[state])
        else:
            print("That is not a state!")
        
# Run it!
main()


        
