# Number Guess Project

#1

I reviewed it many times and still gets this error massage: "File "NumberGuess.py", line 14
user_guess = get_user_guess()"

``````My code is as follow:

## This is a program that rolls a pair of dice and asks the user to guess a number. Based on the user's guess, the program should determine a winner. If the user's guess is greater than the total value of the dice roll, they win! Otherwise, the computer wins. ##

from random import randint
from time import sleep
def get_user_guess():
user_guess = int(raw_input("Guess the result of the two rolling dices: "))
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 = str(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 "The result guess you've enterend is above the possible maximun 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
sleep(1)
total_roll = first_roll + second_roll
print "result..."
sleep(1)
print "%d" % (total_roll)
if user_guess > total_roll:
print "You have won the game!"
return
else:
print "You have lost the game."
return
roll_dice(6)
What i'm missing here?

Thanks!``````

#2

look at this two lines:

``````  sleep(1)
user_guess = get_user_guess()``````

the indent is no match

#3

``````from random import randint
from time import sleep
def get_user_guess():
user_guess = int(raw_input("Guess the result of the two rolling dices: "))
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 = str(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 "The result guess you've enterend is above the possible maximun 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
sleep(1)
total_roll = first_roll + second_roll
print "result..."
sleep(1)
print "%d" % (total_roll)
if user_guess > total_roll:
print "You have won the game!"
return
else:
print "You have lost the game."
return
roll_dice(6)``````

I fixed it, now it syas:
"IndentationError: unexpected indent
\$ python NumberGuess.py
File "NumberGuess.py", line 15
if user_guess > max_val:
^
IndentationError: unexpected indent"

Any advise?

Issue with raw_input
#4

here:

``````  user_guess = get_user_guess()
if user_guess > max_val:``````

this indent levels don't match either. Please check also the lines above and below if you get an indent error

#5

How should I check it?

#6

you can either look at the code, to see if all the indent make sense, or look at the error message and look around the lines of the error message (error messages often include a line number), to see if there is indention that is off.

#7

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