I am a beginner to Python and am just trying to make a simple 'Guess the number' game. I programmed it to tell you weather the number you guessed is higher or lower than the actual number. However, the 'Higher' and 'Lower' appear on the screen a couple of hundred times instead of just one.
Code:
import random
print('Welcome to Guess the Number')
print('Try to guess the number in as few tries as possible')
the_number= random.randint(1, 100)
guess=int(input("Take a guess! "))
tries=1
while guess != the_number:
if guess>the_number:
print('Lower... ')
else:
print('Higher... ')
guess= int(input('Take a guess! '))
tries+=1
print('Well done! The number was', the_number)
print('and it only took u=you', tries, 'tries!')
input('n/nPress the enter key to exit')
Comment