I am making a random number guessing game, and I was wondering if, when your guess is 3 less or more than the answer, it will print something like "Close! The answer was (answer)"
import random
while True:
dicesize = raw_input('What size die do you want to guess from?>')
number = random.randrange(1, int(dicesize))
guess = raw_input('What is your guess?>')
if int(guess) == number:
print 'Correct!'
print " "
else:
print 'Nope! The answer was', number
print " "
(I have a print "" to make a space between each of the loops)
source
share