Python: Assigning user input as key in dictionary
<p><strong>Problem</strong>
I was trying to assign user input as a key in a dictionary. If user input is a key then print out its value, else print invalid key. The problem is the keys and the values will be from a text file. For simplicity I will just use random data for the text. Any help would be appreciated. </p>

<p><strong>file.txt</strong></p>

<p>Dog,bark<br/>
Cat,meow<br/>
bird,chirp<br/></p>

<p><strong>Code</strong></p>

<pre><code>def main():
    file = open("file.txt")
    for i in file:
        i = i.strip()
        animal, sound = i.split(",")
        dict = {animal : sound}

    keyinput = input("Enter animal to know what it sounds like: ")
    if keyinput in dict:
        print("The ",keyinput,sound,"s")
    else:
        print("The animal is not in the list")
</code></pre>