diff --git a/guesser.py b/guesser.py index 6acea9b..4a0fc8d 100644 --- a/guesser.py +++ b/guesser.py @@ -8,30 +8,31 @@ def main(): attempts = 1 # Initial count of attempts. Minimum is 1. - print "How many numbers do you want?" + print( "How many numbers do you want?") # Declare variable to generate random number inside range. - howMany = input("Ammount: ") + howMany = int(input("Ammount: ")) if howMany == 1: - print "Pick a number greater than 1!" + print( "Pick a number greater than 1!") main() # If the number is 1, return to main. else: # if the number is greater than 1, continue. - print 'Guess the number between 1 and {}.'.format(howMany) + print('Guess the number between 1 and {}.'.format(howMany)) randomNumber = random.randint(1, howMany) + found = False # declare found as false. while not found: # while the user has not guessed the correct number. - userGuess = input("Your guess: ") + userGuess = int(input("Your guess: ")) if userGuess == randomNumber: - print "You have guessed the correct number! You used", attempts, "attempts." + print("You have guessed the correct number! You used", attempts, "attempts.") found = True # declare found as true which ends the program elif userGuess > randomNumber: # if the user is less than the generated number - print ("Guess lower!") + print ("Guess higher!") attempts = attempts + 1 # add one attempt to the counter else: - print ("Guess higher!") + print ("Guess lower!") attempts = attempts + 1 # add one attempt to the counter