# Number Guess problem

#1

Hey guys, so i started doing number guess and got pretty far in, however whenever i would enter python NumberGuess.py it would always show up as is the image i linked
.

I watched the youtube video to see what the guy did and i basically had the exact same thing as him yet i still can’t get it to work. Even when i go back to task 17 where it asks for you to give it a try i still get the same result.

here is my code:

``````"""
This is a game to guess the number equal to 2 die's thrown in the simulation!
"""

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 "%d is tool large" % guess
else:
print "Rolling..."
sleep(2)
print "The 1st roll is %d" % first_roll
print "The 2nd 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 "Congratulations! You have won!"
else:
print "Sorry mate, you have lost"

roll_dice(6)
``````

#2

Indentation is essential in its defining the structure of a Python program. Check this line …

``````  def roll_dice(number_of_sides):
``````

Is the `roll_dice` function global in scope, or is it part of the `get_user_guess` function?

#3

you are a certified genius, i spent so long looking at indentation but i never thought of that one, just the ones below it.

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.