Number Guess: Python file not responding. please help


Hi. I have got the correct code and I can’t see anything wrong with it but when I type the file in for the freeform project, nothing happens.
Any ideas?
Happy to provide photos of code and errors.

Here’s the code:

"""This is a number guessing game the idea is that the player/you will guess a number, and the program will decide who the winner is, if the player/you guess is BIGGER than the dice rolled result, then the player/you wins. Otherwise the computer wins"""
from random import randint
from time import sleep
def get_user_guess():
  user_guess = int(raw_input ("Please input your guess, it's two dice!: "))
  return user_guess
def roll_die(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 max value that can be a roll: " + str(max_val)
  sleep (1)
  user_guess = get_user_guess()
  if user_guess > max_val:
    print "Your guess is too big, it's six sides after all!"
    print "Rolling..."
    sleep (2)
    print "The first roll is resulting too: %d" % first_roll
    sleep (1)
    print "The second roll is resulting too: %d" % second_roll
    total_roll = first_roll + second_roll
    print "The total roll is resulting too: %d" % total_roll
    if user_guess > total_roll:
      print "You win!"
      print "You lost!"


Please be sure to include a link to the project when posting a question. Thanks.

Link to project

Python extension course

Your code was formatted to display block structure.


Should this line follow your code and be called from global scope? It is an infinite loop that should crash very quickly.


is this what you mean by linking it?


Yes, that is. Thanks.


A file doesn’t do anything by itself, try running python with the filename as an argument

Or if that’s what you did, then consider what your program does when executed. Maybe the instructions in your file amount to doing nothing.
You can test with a simpler program which you know does something, to determine if you’re running it correctly

print 'hello world'


I tried printing “Yay” and it still doesn’t work, nothing responds. What do you mean by running it as an argument?


Python is a program. The way you execute python programs is by running python, and telling it which file to execute - python path/to/

Your code says to make two imports and create two functions. After that it’s done, that’s all it does.

By running a program that ONLY contains a print, you could determine if the problem is with the code itself or not. I suspect you put the print somewhere in your already existing code though, but already knowing that prints don’t come out of there, that defeats the purpose.


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