0

I have seen similar posts, but I can't seem to apply those answers to my problem. I am not able to see exactly what I am doing wrong here. I need to print each of 5 scores, and their total.

for i in range(5):
    arrow = win.getMouse()
    score = findScore(arrow)
    print('Current Shot: {:}'.format(score))
    total = total + score
    print('Total: {:}'.format(total))

Thank you in advance to anyone who may be able to help.

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
J. Adams
  • 11
  • 3
  • This isn't really a duplicate (either of how it was marked before, or how I tried to clean it up), but it *is* a simple typo that should have been closed as such. Voting to delete. – Karl Knechtel Sep 09 '22 at 11:20

1 Answers1

0

In the first iteration of your for loop you are referencing total in the line total = total + score before your program knows what total is. Initialize it ahead of time with total = 0 before your for loop. If you are providing an initial value for total in earlier code, make sure that this code is actually run.

elethan
  • 16,408
  • 8
  • 64
  • 87