I am working on the Number Guess project in Python, I can’t get the get_user_guess function to work, please take a look at my code, I can’t figure out what is wrong with it.
When I run the program it starts running, but never asks me for the input from the first function. It doesn’t give me an error code, just stops running because there is no user input.
I am expecting it to ask me for the guess. Any ideas on how to make this happen?
""" This program will roll a pair of dice, add the value of the roll, ask the user to guess a number, compare the user's guess to the total value, and determine if the computer of the user wins """ from random import randint from time import sleep def get_user_guess(): guess = int(raw_input("Guess a number: ")) 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 maxinum possible value is: %d" % max_val guess = get_user_guess if guess > max_val: print "Your guess is higher than the maximum value." else: print "Rolling..." sleep(2) print "Your first roll is: %d" % first_roll sleep(1) print "Your second roll is: %d" % second_roll sleep(1) total_roll = first_roll + second_roll print "Your total roll is: %d" % total_roll sleep(1) print "Result..." sleep(1) if guess > total_roll: print "You Won!" else: print "You lost, sorry..." roll_dice(6)