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.

J. Adams
  • 11
  • 3

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
  • 15,400
  • 8
  • 58
  • 83
  • Thank you, I appreciate your help. I tried that, and now I get TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' I am apparently doing something majorly wrong here and need to get some rest and start over. – J. Adams Oct 31 '16 at 01:59
  • @J.Adams OK. If you can't figure it out, please show more of your code in your original post (particularly, where `total` is first set, and the places where its value is modified), and comment on this answer again so I know your original question has been updated. Good luck! – elethan Oct 31 '16 at 02:18