0

I need my code to output all the user in the class's score but it only output one user answer a lot of times. Please can you help. Thanks in advance.

filename = class_name + ".csv"

csv.register_dialect('pipes', delimiter='|')

with open(filename, 'a',newline='') as fp:
    a = csv.writer(fp, delimiter=',')
    data=[[name,score]]              
    a.writerow(data)


if get_bool_input("Do you wish to view previous results for your class"):
    with open(filename, 'r') as f:
        reader = csv.reader(f, dialect = 'pipes')
        for row in reader:
            print (data)
else:
    input ("Press any key to exit")
0

1 Answer 1

3

You should be doing print(row).

print(data) just prints the last output data list that you wrote.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.