Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Won't let me end a loop
#2
It's not leaving the loop because you never change gameRun. You only change gameTrue, not gameRun. Furthermore, you are only changing gameTrue within the checkX function. Even if you changed that to gameRun, it would be a different gameRun. This is called the scope of the variable. What you need to do is put the following line at the end of the definition of checkX: return gameTrue. That will make the value of any call to checkX the value of gameTrue when it ran. Then, in your loop, change the call to checkX to gameRun = checkX(). That will change gameRun to False whenever someone wins the game, ending the game
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Won't let me end a loop - by mzmingle - Aug-06-2017, 07:07 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 07:55 PM
RE: Won't let me end a loop - by mzmingle - Aug-06-2017, 08:03 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 08:05 PM
RE: Won't let me end a loop - by mzmingle - Aug-06-2017, 08:28 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 08:48 PM
RE: Won't let me end a loop - by mzmingle - Aug-06-2017, 08:56 PM
RE: Won't let me end a loop - by ichabod801 - Aug-06-2017, 09:58 PM

Forum Jump:

User Panel Messages

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