There are two main problems in your code.
First, you do not call the upper method, but simply refer to it. You should call it (via Question.upper() ), as w00t does in your answer.
Putting some diagnostic print statements inside your loop would be a good way to see this (especially listing str(Question.upper) ) (Tangent: Question is a bad name for a variable that contains the answer to a question about the program asked by the user)
Secondly, deleting already seen items from the list that you are repeating will skip the values. In fact, you do not need to copy the entire list to deal with this - just repeating it otherwise is enough to fix the problem.
Finally, a couple of minor cosmetic points is that raw_input() takes a prompt argument, so you donβt need a separate print statement, and calling upper() on the line itself will always return the line:
titles_list = ["English", "Math", "History", "IT", "Biology", "Spanish"] prompt = ("Do you want to keep the title: {}\n" "or Delete it? Input Y for keep, N for Delete: ") for title in reversed(titles_list): answer = raw_input(prompt.format(title)) if answer.upper() == "N": titles_list.remove(title) print titles_list
ncoghlan
source share