Code failure


#1

the code fails on when the code reaches second_roll

“”“To guess a number”""
from random import randint
from time import sleep
def get_user_guess():
guess = int(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(“No guessing higher than maximum possible value !”)
else:
print (“Rolling”)
sleep(2)
print (“The 1st roll is %d” %first_roll)
sleep(1)
print (“The second_roll is %d”%Second_roll)
sleep(1)
total_roll= first_roll+second_roll
print (“The total value is: %d” %total_roll)
print(“Result…”)
sleep(1)
if guess==total_roll:
print (“You won!”)
else:
print (“You lost,try again”)
roll_dice (30)


#2

Typing error creates undefined variable.


#3

thanks i didn’t notice


#4

How could we make this a game that keeps going?