Issue with raw_input


#1

I’m having issue with my code. When I run the program it doesn’t ask for the user’s raw_input. I’ve copy pasted somebody else’s code that looked identical to mine to try and see if they had the same issue, but they’re code ran just fine.

Here’s the link to the code I compared to mine. Number Guess Project




from random import randint
from time import sleep
def get_user_guess():
  user_guess = int(raw_input("Guess a number fam: "))
  return user_guess
def roll_dice(number_of_sides):
  first_roll = randint(1, number_of_sides)
  second_roll = randint(1, number_of_sides)
  max_val = str(number_of_sides * 2)
  print "Max value is " + str(max_val)
  sleep(1)
  user_guess = get_user_guess
  if user_guess >= max_val:
    print "# too big hoe"
    return
  else:
    print "rolling..."
    sleep(2)
    print "The first roll is %d" % first_roll
    sleep(1)
    print "The second roll is %d" % second_roll
    sleep(1)
    total_roll = first_roll + second_roll
    print "Total roll is %d" % total_roll
    sleep(1)
    if user_guess > total_roll:
      print "Wow good job loser"
      return
    else: 
      print "haha loser"
      return
      
      
roll_dice(6)



#2

Please remember to include a link to the exercise when posting a question. I really helps us along. Thanks.

The new course track may expect Python 3 (just guessing at this point) but one quick check and we’ll know. Waiting for that link.

In the meantime,

The function needs to be invoked…

... get_user_guess()

As functions go, yours can be refactored…

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

#3

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