Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with my code?
#2
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, 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
Reply


Messages In This Thread
Problem with my code? - by Darbandiman123 - Sep-29-2018, 12:35 PM
RE: Problem with my code? - by gruntfutuk - Sep-29-2018, 01:50 PM
RE: Problem with my code? - by Darbandiman123 - Sep-29-2018, 01:54 PM
RE: Problem with my code? - by gruntfutuk - Sep-29-2018, 01:55 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020