Number Guess Project

I have been stuck on the Number Guess project for awhile now. The only thing I cannot get to work in the programs code is getting it to allow me to input a guess. Does anyone have an idea on what I need to fix to get this to work? Any help or suggestions would be greatly appreciated!


This program is a number guessing game.


from random import randint

from time import sleep

def get_user_guess():

guess = int(raw_input("Enter guess: "))

return guess

def roll_dice(number_of_sides):

first_roll = randint(1, number_of_sides)

second_roll = randint(1, number_of_sides)

max_val = number_of_sides * 2

print “The maximum possible value is: %d” % max_val

guess = get_user_guess

if guess > max_val:

print "Number exceed max value"


guess <= max_val;

print "Rolling..."


print "The 1st roll is: %d" % first_roll


print "The 2nd roll is: %d" % second_roll


total_roll = first_roll + second_roll

print "Result..."


if guess == total_roll:

  print "You won!"


  print "You lost!"


Is this project in the Python 2 course? There may be an issue with raw_input() which means you might have to manually create a value instead of getting user input. The get_user_guess() function could simply return a random integer in the same range as the roll_dice() function. At least then you can see the code run.

Yes, it is in the Python 2 course. I think I am going to move forward with my lessons and comeback to that project when I feel like I have a better grasp on Python.

Just keep in mind that raw_input() may not work and will need to be simulated so you can see your code run to completion.