Number Guess problem


Hi! Trying to figure out why I get this error, and cannot find the problem. I have checked the community too, and seems to be the same code as other members… Any idea, please? (I have tried to upload a screengrab, but couldn’t)

from random import randint
from time import sleep

def get_user_guess():
  guess = int(raw_input("What is your 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 "Your guess is invalid"


By the way, the error message I get is this:

Name error: name ‘max_val’ is not defined (referring to line print “The maximum possible value is: %d” % max_val


max_val has a local scope, it only exist within the roll_dice function


sorry but, what does that mean? Is it that the print message should be indented inside the def roll_dice?


Ok, that was it, solved. Thanks