Take the 2-minute tour ×

I keep getting an attribute error with this code. Does anyone have any ideas why this might be the case? I know 'str' cannot be appended but I am trying to append the list... any help would be greatly appreciated!

elif choice == "1":
    eval_type = open("eval_type.txt", "r+")
    for line in eval_type:
        new_eval = input("What do you want to call the new evaluation?")
        points = input("How many points is this type worth?")
        if new_eval in line:
            print("\n", new_eval, "already exists.")
            print (new_eval, "has been added.")
share|improve this question

1 Answer 1

eval_type in your snippet is not a list; its actually a file type; which you cannot append to.

>>> x = open('test.txt','w')
>>> type(x)
<type 'file'>

You should initialize an empty list before the for loop and use that instead.

share|improve this answer

Your Answer


