(Solved)Stuck in Dice Game's code

Hi all!

I am stuck in Dice Game (https://www.codecademy.com/courses/learn-python/projects/number-guess). I check my code with the tutorial video line by line. However, I still cannot find where does my code go wrong.

from random import randint
from time import sleep

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

def roll_dice(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 maximum possible value is: %d" % max_val 
  guess = get_user_guess()
  if guess > max_val:
  print "No guessing higher than the maximum possible value!"

  roll_dice(6)

Thanks in advance,

Wansiya

1 Like

What is working differently then expected? Go wrong how?

1 Like

Firstly, the output kept showing that there is an error in this line.

Now I figured out that I have to add Multi-line comment at the first line. Previously, I did not think that this will influence program running.

Thank you very much, :slight_smile:

Wansiya

1 Like

you don’t have to it, by doing this you might have solved the issue as well, but you do not have to add a multiline comment, you need to ensure you indent is properly, that after an if condition you indent the code which should be nested in if clause/body.

1 Like

Oh I got you! Thank for your valuable suggestions. I also adjusted the indent after the last if condition to make the print statement be not in the same row position in the next line.

You are so fantastic!

1 Like