Python- how to convert lines in a .txt file to dictionary elements?

try this:

d = {}
with open('text.txt') as f:
    for line in f:
        key, value = line.strip().split(':')
        d[key] = int(value)

You are appending to d[key] as if it was a list. What you want is to just straight-up assign it like the above.

Also, using with to open the file is good practice, as it auto closes the file after the code in the 'with block' is executed.