Problem: Guess Number The computer randomly generates a number. The user inputs a number, and the computer will tell you if you are too high, or too low. Then you will get to keep guessing until you guess the number.
import random guessesTaken = 0; # Getting User Information print("Hello ! What is your name?") name = input() number = random.randint(1, 20) print("Well, " + name + ' I am thinking of a number between 1 and 20') while guessesTaken < 6: print('Take a guess.') #There are four spaces in front of print guess = int(input()) guessesTaken = guessesTaken + 1 if guess < number: print("Your guess is too low.") if guess > number: print("Your guess is too hight.") if guess == number: break if guess == number: guessesTaken = str(guessesTaken) print("Good Job, " + name + "! You guessed my number in " + guessesTaken + ' guess') if guess != number: number = str(number) print('Nope. The number I was thinking of was ' + number)