Unbound Local Error with global variable

前端 未结 3 1901
别跟我提以往
别跟我提以往 2021-01-12 05:26

I am trying to figure out why I get an UnboundLocalError in my pygame application, Table Wars. Here is a summary of what happens:

The variables, REDGOLD

3条回答
  •  走了就别回头了
    2021-01-12 05:54

    You need to declare the variable as global in each scope where they are being modified

    Better yet find a way to not use globals. Does it make sense for those to be class attributes for example?

提交回复
热议问题