Sep-29-2018, 01:50 PM
(This post was last modified: Sep-29-2018, 01:50 PM by gruntfutuk.)
When you reassign a value to count in your check_Count function, you are doing so to a local variable.
Check the id of count,
I also note you are using recursion (calling a function before returning from it).
(As you are learning Python, I strongly recommend you use Python 3 rather than legacy Python. (Support for Python 2 ends on 1st January 2020.) Generally, I'd suggest that only experienced programmers responsible for maintaining old code, or those with a absolute dependency on a library that has not yet been updated and for which there are no Python 3 compatible alternatives should be using Python 2. Python 3 has many advances, fixed a lot of issues, and is more performant.)
Check the id of count,
print('initial', id(count))
, after first initialising, and also before and after the increment in the function.I also note you are using recursion (calling a function before returning from it).
(As you are learning Python, I strongly recommend you use Python 3 rather than legacy Python. (Support for Python 2 ends on 1st January 2020.) Generally, I'd suggest that only experienced programmers responsible for maintaining old code, or those with a absolute dependency on a library that has not yet been updated and for which there are no Python 3 compatible alternatives should be using Python 2. Python 3 has many advances, fixed a lot of issues, and is more performant.)
I am trying to help you, really, even if it doesn't always seem that way