Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
While loop confusion
#3
You want to indent the last two lines of code once. Then they will be part of the outer while loop, the one that tests choice.

But are you sure this is the code you are running? It doesn't produce the behavior you mention. It goes into an infinite loop because choice never changes in the loop. It never asks if you want to play again.

Note that if the player does want to play again, you need to reset num to a new random value. Otherwise the old guess will still equal the old num, and the inner while loop will never activate.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
While loop confusion - by juliabrushett - Jun-23-2018, 06:54 AM
RE: While loop confusion - by Leonzxd - Jun-23-2018, 07:21 AM
RE: While loop confusion - by ichabod801 - Jun-23-2018, 07:29 AM

Forum Jump:

User Panel Messages

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