No If-loop exec in Dice guessing game


Hello everyone!

I am following along the Dice guessing game project here ( and have encountered an issue when attempting to test numbers that should trigger a “too high” warning. I get no output when entering in a value higher than max_val. It doesn’t seem to evaluate my if loop whatsoever. I have entered in print statements to check values of variables and they all seem to report the right numbers up to the if statement.

Here is my code:

from random import randint
from time import sleep

def get_user_guess():
	user_guess = int(raw_input("Guess the value of the two dice: "))
  	return user_guess

def roll_dice(number_of_sides):
	first_roll = randint(1,number_of_sides)
  	print first_roll
	second_roll = randint(1,number_of_sides)
  	print second_roll
	max_val = 2 * number_of_sides
	print "The maximum value is %d" % max_val
	guess = get_user_guess()
  	print guess, max_val
  	if guess > max_val:
    		return "Guess too high"

If you are familiar with this project from CodeAcademy, you will notice it is not near done, I was instructed to test my code at this point and am stuck on this essential issue. thanks for any pointers you may have.


Hi @emptytech

The indentations of the lines in your code include various combinations of tabs and spaces. This can cause problems in a Python program. Use either tabs or spaces for indentation in an individual Python program, rather than a combination of both.

The following is an example of a line in your code with indentation consisting of four spaces followed by two tabs …

    		return "Guess too high"

For the current Codecademy Python project, as well as most or all others, use two spaces for each level of indentation. For the code that you posted here, check each line and redo its indentation accordingly, where necessary.


Ah, yes I was having loads of issues with indents. I will go back and redo everything with 2 spaces per level of indention.
thank you for the quick and friendly advice!