 # Roll dice

``````"""
Roll the dice
"""

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 = random(1, number_of_sides)
second_roll = random(1, number_of_sides)
max_val = number_of_sides * 2
print "Max possible valuse:%d" % max_val

guess = get_user_guess()

if guess > max_val:
print "invalid"

roll_dice(6)

``````

no ouput:

\$ python NumberGuess.py

https://www.codecademy.com/courses/learn-python/projects/number-guess

the function call (which is suppose to execute the function) is nested within the function.

1 Like
``````"""
Roll the dice
"""

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 = random(1, number_of_sides)
second_roll = random(1, number_of_sides)
max_val = number_of_sides * 2
print "Max possible valuse:%d" % max_val

guess = get_user_guess()

if guess > max_val:
print "invalid"
else:
print "rolling....."
sleep(2)
print "1st roll %d" % first_roll
sleep(1)
print "2nd roll %d" % second_roll
sleep(1)

total_roll = first_roll + second_roll
print "Total %d" %total_roll
print "result..."
sleep(1)

if guess == total_roll:
print ("WON")
else:
print "lost"

roll_dice(6)
``````

can you please let me know in which line i need to correct?

this one:

``````  roll_dice(6)
``````

its nested inside the function, which prevents its from executing the function. The function call should be outside/after the function.

1 Like