I have a text file that contains State names and their corresponding Capital. I am trying to read the lines one at a time and separate the State from the Capital. Then I want to add the States and Capitals as key and value pairs in my dictionary respectively. I am still very new to programming so any help would be appreciated. Currently, I am struggling to separate the text file one line at a time. This is what I have so far.
def main():
    dict = {}
    file = open(input("Please enter the name of the file: "))
    lines = file.readline()
    while lines:
        text = lines.split(",")
        lines = file.readline()   
Example of Text File:
Arizona,Phoenix
Arkansas,Little Rock
California,Sacramento
Colorado,Denver
Connecticut,Hartford
Florida,Tallahassee
Georgia,Atlanta
 
    