Skip to main content
added 15 characters in body
Source Link
aIKid
  • 28.5k
  • 5
  • 41
  • 65

Yep, it's a scope problem. In the beginning of your main() function, add this:

global firstevent 

That should done it. Any variable that is not defined inside a function, is a global. You can access it straightly from any function. However, to modify the variable you'll need to write global var in your function.

Example

This creates a local variable "firstevent" on the function:

firstevent = 0 def modify(): firstevent = 1 

andAnd this modifies the global variable 'firstevent'

firstevent = 0 def modify(): global firstevent firstevent = 1 

Yep, it's a scope problem. In the beginning of your main() function, add this:

global firstevent 

That should done it. Any variable that is not defined inside a function, is a global. You can access it straightly from any function. However, to modify the variable you'll need to write global var in your function.

This creates a local variable "firstevent" on the function:

firstevent = 0 def modify(): firstevent = 1 

and this modifies the global variable 'firstevent'

firstevent = 0 def modify(): global firstevent firstevent = 1 

Yep, it's a scope problem. In the beginning of your main() function, add this:

global firstevent 

That should done it. Any variable that is not defined inside a function, is a global. You can access it straightly from any function. However, to modify the variable you'll need to write global var in your function.

Example

This creates a local variable "firstevent" on the function:

firstevent = 0 def modify(): firstevent = 1 

And this modifies the global variable 'firstevent'

firstevent = 0 def modify(): global firstevent firstevent = 1 
added 13 characters in body
Source Link
aIKid
  • 28.5k
  • 5
  • 41
  • 65

Yep, it's a scope problem. In the beginning of your main() function, add this:

global firstevent 

That should done it. Any variable that is not defined inside a function, is a global. You can access it straightly from any function. However, to modify the variable you'll need to write global var in your function.

This creates a local variable "firstevent" on the function:

firstevent = 0 def modify(): firstevent = 1 

and this modifies the global variable 'firstevent'

firstevent = 0 def modify(): global firstevent firstevent = 1 

Yep, it's a scope problem. In the beginning of your main() function, add this:

global firstevent 

That should done it. Any variable that is not defined inside a function, is a global. You can access it straightly from any function. However, to modify the variable you'll need to write global var in your function.

This creates a local variable "firstevent" on the function:

firstevent = 0 def modify(): firstevent = 1 

and this modifies the global variable

firstevent = 0 def modify(): global firstevent firstevent = 1 

Yep, it's a scope problem. In the beginning of your main() function, add this:

global firstevent 

That should done it. Any variable that is not defined inside a function, is a global. You can access it straightly from any function. However, to modify the variable you'll need to write global var in your function.

This creates a local variable "firstevent" on the function:

firstevent = 0 def modify(): firstevent = 1 

and this modifies the global variable 'firstevent'

firstevent = 0 def modify(): global firstevent firstevent = 1 
Source Link
aIKid
  • 28.5k
  • 5
  • 41
  • 65

Yep, it's a scope problem. In the beginning of your main() function, add this:

global firstevent 

That should done it. Any variable that is not defined inside a function, is a global. You can access it straightly from any function. However, to modify the variable you'll need to write global var in your function.

This creates a local variable "firstevent" on the function:

firstevent = 0 def modify(): firstevent = 1 

and this modifies the global variable

firstevent = 0 def modify(): global firstevent firstevent = 1