why is += operator not working

This question already has an answer here:

  • Using global variables in a function other than the one that created them 18 answers

  • You mixed two different ideas in Python, a " global statement" and an "augmented assignment statement."

    A " global statement" has a very simple syntax:

    "global" identifier ("," identifier)*
    

    No expression is allowed in a global statement.

    Perhaps you wanted to say:

    global counter
    counter += 1
    
    链接地址: http://www.djcxy.com/p/23896.html

    上一篇: 布尔如果在Python中声明

    下一篇: 为什么+ =操作符不工作