using global variables inside a function

I used the global declaration and it works.

You have to pass it to the function:

or declare it global:

If the variable isn’t global but is instead defined in an outer function, the first option (passing as an argument) works just the same:

Alternatively, create a closure by declaring the variable in a use clause.

Leave a Reply

Your email address will not be published. Required fields are marked *