# NumberGuess game

#1

Can anyone help me out & tell me what I’m doing wrong with my code here. I’ve been over it many times over the last day or so and I’m guessing it’s something small that I keep overlooking. It keeps coming up with errors…

``````
"""This is a game to see if you can guess a number that is higher than the total value of the dice roll """
from random import randint
from time import sleep
def get_user_guess():
user_guess = int(raw_input("Guess a number: "))
return user_guess

def roll_dice(number_of_sides):
first_roll = randit(1, number_of_sides)
second_roll = randit(1, number_of_sides)
max_val = number_of_sides * 2
print "The maximum possible value is: " + str(max_val)
sleep(1)
user_guess = get_user_guess()
if user_guess > max_val:
print "Your guess is higher than the total possible value!"
return
else:
print "Rolling..."
sleep(2)
print "The first value is: %d" % first_roll
sleep(1)
print "The second value is: %d" % second_roll
total_roll = first_roll + second_roll
print "The total value of the roll is: %d" % total_roll
sleep(1)
if user_guess > total_roll:
print "You Won!"
return
else:
print "You lost, try again."
return

get_user_guess()
roll_dice(6)
``````

#2

it seems you made a typo here:

``````  first_roll = randit(1, number_of_sides)
second_roll = randit(1, number_of_sides)
``````

it should be `randint`, you miss a `n` in `int`

its short for `rand`om `int`eger, maybe that helps you remember it

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.