Program simply will not run


#1

I am not getting any error codes but when I type python NumberGuess.py into the command prompt it does nothing. My program doesn't run. If I move indentation out of place it will complain but once I fix it it just continues displaying nothing.

As far as I can tell from reviewing the hints I haven't done anything differently than the hints themselves. It may be something really simple but I can't figure it out.


from random import randint
from time import sleep

def get_user_guess():
	ug = int(raw_input("Guess a number:"))
	return ug

def roll_dice(NOS):
  roll1=randint(1,NOS)
  roll2=randint(1,NOS)
  MaxVal=NOS*2
  print "The maximum Value is: " + str(MaxVal)
  ug=get_user_guess()
  if ug>MaxVal:
    print"This is an invalid guess."
    return
  else:
    print "Rolling, rolling, rolling..."
    sleep(2)
    print "The first value is: %d" %(roll1)
    sleep(1)
    print "The second value is: %d" %(roll2)
    sleep(1)
    total=roll1+roll2
    print "The total is: %d" %(total)
    print "Computing Result..."
    sleep(1)
    if ug>total:
      print "You won...I guess"
      return
    else:
      print "I WON! MUAHAHAHAHAHAHAHA!"
      return
    
  roll_dice(6)


#2

Hi,

the roll_dice(6) part is indented, and thus part of the function definition.


#3

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