[Tutor] Will the following code ever exit?

Andre Engels andreengels at gmail.com
Sat Sep 17 10:13:32 CEST 2005


On 9/17/05, Nathan Pinno <falcon3166 at hotmail.com> wrote:
> Thanks, but when I run the code, even after that change it always just
> prints the questions, correct questions(which is always 0), and percent
> right(always 0). How do I make it enter the quiz.
> Thanks,
> Nathan Pinno

Your program has:

q = random.choice(range(15,31)
cq = 1
while cq >= q:

q has a value between 15 and 31, cq equals 1. 1 is not greater than or
equal to any number between 15 and 31, so cq >= q is always false. I
think you meant to write:

while q >= cq:

Andre Engels


More information about the Tutor mailing list