What's causing this variable referenced before assignment error?

后端 未结 3 975
深忆病人
深忆病人 2021-01-21 18:58

This is the code that I am working with:

import pygame

global lead_x
global lead_y
global lead_x_change
global lead_y_change

lead_x = 300
lead_y = 300
lead_x_c         


        
3条回答
  •  耶瑟儿~
    2021-01-21 19:23

    If you need to modify a global variable from inside a function you need to use the global keyword: global lead_x in this case, before any assignment

提交回复
热议问题