Please help with NumberGuess exercise!


When i try to run my code on NumberGuess, the console asks for my input (However, it does not show the text i put in for “raw_input”). When I enter a number, i get “bash: x: command not found.”

Please Help!

from random import randint
from time import sleep
def get_user_guess():
  user_guess = int(raw_input('Enter your guess:'))
  return user_guess
def roll_dice(number_of_sides):
  first_roll = randit(1, number_of_sides)
  second_roll = randit(1, number_of_sides)
  max_val = number_of_sides * 2
  print "The maximum possible value is:" + str(max_val)
  user_guess = get_user_guess()
  if user_guess > max_val:
    print "Guess is invalid."
    print "Rolling..."
    print "The first value is: %d" % first_roll
    sleep (1)
    total_roll = first_roll + second_roll
    print total_roll
    print "Result..."
    if user_guess > total_roll:
      print "Congratulations!! You Won!!"
      print "Aww!! Better Luck Next Time!!"


Well, first of all, there is a typo here:

should be randint.

also, it looks like you are trying to call your roll_dice function, inside of it’s definition, and I don’t believe this will work.


duh what a dumb mistake. thank you so much. got it running!


not a dumb mistake, everyone makes typo errors :wink:


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