[Solved] Python 3.3.1 While Loops [duplicate]


You never update the value of GuessedNumber inside the loop. Therefore, if the code enters the loop, it will never leave it because RandomNumber != GuessedNumber will always be true.

You need to do something like this:

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

GuessedNumber=int(input("Guess any whole number between 0 and 100! "))

while RandomNumber != GuessedNumber:
    print("Unlucky guess again!")
    GuessedNumber=int(input("Guess any whole number between 0 and 100! "))

print("Well done you gessed correctly!")

Notice how the value of GuessedNumber is now updated with each iteration of the loop.

1

solved Python 3.3.1 While Loops [duplicate]