Why does python modify the global int variable in the method of the class without reporting an error but invalid after adding global?

I am trying to write a command line Mini Game with python, in which there is a class that needs to modify a global int variable. I obviously have added global ( Baidu result , etc.), and the code has not reported an error, but why has it not been modified when accessing the variable again? Solution ~
Environment: mac+python3.6+pycharm+ipython
my Code:

-sharp python
obj = {"s": []}
sunlight = 0


class GameObject:
    indicating_char = ""

    def __init__(self, pos):
        self.pos = pos
        obj[self.indicating_char].append(self)

    def __str__(self):
        return self.indicating_char

    def step(self): pass


class Sunflower(GameObject):
    def __init__(self, pos):
        self.indicating_char = "s"
        super().__init__(pos)

    def step(self):
        print("executing")
        global sunlight
        sunlight += 50

-sharp ipython
In [1]: from game import *

In [2]: Sunflower(0).step()
executing

In [3]: sunlight
Out[3]: 0
Mar.21,2021

use it this way:

import game


game.SunFlower(0).step()
print(game.sunlight)

declare the global variable at the beginning:

obj = {'s': []}
global sunlight
sunlight = 0

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9df97-4775b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9df97-4775b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?