Home>

I want to use global functions in Python.
Executefunction taskevery 0.1 second, andprintthe count countercntin it, andlistStores the values ​​obtained by other functions.
Whenprintis set,cntis 0 each time, so it seems that the variable that has been initialized outside the functiontaskhas been read. I think.
The following error will also occur.

Error message
SyntaxError: name 'cnt' is parameter and global
Applicable source code
#Initialize
    cnt = 0
    list = []
    def task (cnt, list):
        global cnt
        global list
        cnt + = 1
        print (cnt)
    signal.signal (signal.SIGALRM, task)
    signal.setitimer (signal.ITIMER_REAL, 0.1, 0.1)

Where is the cause?