Python NameError, variable 'not defined'

前端 未结 3 767
梦谈多话
梦谈多话 2020-12-12 04:12

the error it returns is:

NameError: name \'lives\' is not defined

I know the code isn\'t as efficient as possible, this is one of my first

3条回答
  •  Happy的楠姐
    2020-12-12 04:22

    You didn't declare lives to be global inside main(), so it is local to that function.

    def main():
        global guess, rand_num, lives
        ...
    

提交回复
热议问题