Does anyone know why I get number_of_sides not defined?
https://www.codecademy.com/es/courses/learn-python/projects/number-guess?action=resume_content_item
Here’s the code
“”"The program should do the following:
Roll a pair of dice.
Add the values of the roll.
Ask the user to guess a number.
Compare the user’s guess to the total value.
Determine the winner (user or computer)."""
#Imported functions
from random import randint
from time import sleep
#User number guess
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 “Maximum values is: %d” % max_val
guess = get_user_guess()
if guess > max_val:
print “Your guess is invalid”
roll_dice(6)