Python 2 Number Guess Project: Can't get the terminal to display a question

Hi, I have been working on the Number Guess Project in Learn Python 2 and I have been having some trouble to get the Terminal to display a question that I have coded using the raw_input function. I have worked until the 17th step and my code is as follows:

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 maximum possible value is %d." % max_val
  guess = get_user_guess()
  if guess > max_val:
    print "Please guess a number under the maximum value." 

When I type “python NumberGuess.py” into the terminal nothing happens. Thank you for your help.

Unless guess is greater than max_val then there is nothing to print. You also have to below **roll_dice(number_of_sides) call that same function below so that you feed it an int to make max_val work. The main part of the program that does the work comes after this in the else statement in that function.

1 Like

But wouldn’t it still display the question that is asked using the raw_input function?

I believe that the problem here is,
Why would Python ask the question in the first place?
Think about what you want your code to do.
Then think about what it’s supposed to do.

There is a difference between defining a function and calling it.