I'm a beginner in programming. I'm trying to compare two lists and save the differences in a third list.
How would you copy the incorrect values to a third list?
I'm sure there are more efficient ways of coding, but I need to work with what I have here (unless it can't be fixed).
mc_answers is [A, C, A, A, D] I'm trying to compare it to whatever the user input was, so if input_list was [A, A, A, A, A,], w_answers would be [C, D] (function user_input was assigned to input_list to make it easier to work with).
def wrong_input(input_list, mc_answers):
print()
wrong_answers=[]
for i in range (5):
while input_list[i]!=mc_answers[i]:
wrong_answers.append(input_list[i])
return wrong_answers
And:
def main():
mc_answers=['A', 'C', 'A', 'A', 'D']
display_test()
input_list=user_input()
print(wrong_input(input_list, mc_answers))
def user_input():
user_answers=[]
print()
for i in range (5):
user_answers.append(input('\nAnswer'+str(i+1)+ ': '))
return user_answers
def wrong_input(input_list, mc_answers):
print()
w_answers=[]
for i in range (5):
while input_list[i]!=mc_answers[i]:
w_answers.append(input_list[i])
return w_answers
main()