# Number Guess invalid syntax on line 29

#1

Hello Boys and Girls
The Terminal Window shows me a Syntax Error on line 29 which i do not find out where the problem is.

line 29 is below at
print "The maximum possible value is: " + str(max_val) sleep(1)

Do You have any idea what is wrong at this stage?

"""
Wanna play a game? In this project, we'll build a program that rolls a pair of dice and asks the user to guess a number. Based on the user's guess, the program should determine a winner. If the user's guess is greater than the total value of the dice roll, they win! Otherwise, the computer wins.

The program should do the following:

Randomly roll a pair of dice
Add the values of the roll
Ask the user to guess a number
Compare the user's guess to the total value
Decide a winner (the user or the program)
Inform the user who the winner is
"""

``````from random import randint #import only functionality that is required""
from time import sleep

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

def roll_dice(number_of_sides):
first_roll = randint(1,number_of_sides)

def roll_dice(number_of_sides):
second_roll = randint(1,number_of_sides)

max_val = number_of_sides * 2

print "The maximum possible value is: " + str(max_val) sleep(1)

user_guess = get_user_guess()

def roll_dice(number_of_sides):
# checks if the user's guess is greater than the maximum value
user_guess = get_user_guess()
if user_guess > max_value:
print "No guessing higher than the maximum possible value"
return
else:
print "Rolling..."
sleep(2)
#.formatting, d'ont use %s, but use %d = %s formats string variables, while %d formats integers
print "The first value is: %d" % first_roll
sleep(1)

def roll_dice(number_of_sides):
print "Rolling..."
sleep(2)
print "The second value is: %d" % second_roll
sleep(1)

total_roll = first_roll + second_roll
if user_guess > total_roll:
print "You won!"
return

roll_dice(6)``````

#2

why would you put print and sleep at the same line?

#3

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