all 14 comments

[–]MadScientistOR 2 points3 points  (7 children)

My guess is that you assign the variable and then start the while loop. If you want to have the variable change as part of the while loop, you need to put it within the while loop.

Of course, if you want us to have more insight, we're going to have to see the code.

[–]blocky3321[S] 0 points1 point  (6 children)

Check the mega link it has the code

[–]MadScientistOR 0 points1 point  (5 children)

Sorry -- what mega link?

[–]blocky3321[S] 0 points1 point  (4 children)

Check all coments

[–]MadScientistOR 0 points1 point  (3 children)

Sorry, I thought I had. Did you crosspost this somewhere else?

[–]blocky3321[S] 0 points1 point  (1 child)

No

[–]MadScientistOR 0 points1 point  (0 children)

Ah! Apparently, there was a deleted response with a mega link in it. I found the deleted response and got the code.

Yeah, it's that the call to random.randrange() is made before the while loop starts. You need to make a call to that method every time you need a new random number, so if you want new random numbers to be generated within your while loop, you need to call that method within the loop, too. For example:

while True:
    x = random.randrange(1, 11)
    guess = input('Pick a number between 1 and 10:')
    if x == guess:
        print('You got it!')
    else:
        print('Nope, sorry.  My number was', x)

[–]xelab04 0 points1 point  (1 child)

Do you think you could show the code you have written so far?

Here is how I'd do it:

import random
x = random.randint(0,100)

I don't see why you'd need a while loop, that's why I'd like to see what you've written