Nov-25-2017, 03:38 PM
(This post was last modified: Nov-25-2017, 03:38 PM by SkitzGerald.)
import random from random import randint x = [random.randint(1,100)] print("Guess a number between 1 and 100.") while True: guess = input("") if str(guess) == str(x): print("Congratulations!") elif str(guess) < str(1) or str(guess) > str(100): print("You have to choose a number between 1 and 100.") print("Please guess again.") elif str(guess) < str(x): print("Please choose a higher number.") elif str(guess) > str(x): print("Please choose a smaller number.")
#The problem is, is when I type in any number from 10 - 99 it forces the first elif statement to resolve and tells me to pick a number between 1 and 100. However if I type in 100 it tells me to pick a higher number.
When I change str(100) to str(99) the program works until I input 100 or higher then it tells me to pick a higher number. What am I doing wrong?
[python][/python]