






def get_user_guess():
guess = int(raw_input("Input ur guess: "))
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 "u stupid idiot. U should guess a number less than or equal to 12"
else:
print "Rolling ..."
sleep(2)
print "the first dice shows %d" % (first_roll)
sleep(1)
print "the second dice shows %d" % (second_roll)
sleep(1)
total_roll = first_roll + second_roll
print "the total of both dices is %d" % (total_roll)
print "The result ..."
sleep(1)
if guess == total_roll:
print "U have won !! Ur guess matches with the rolled value"
else:
print "Nah ... better luck next time"
roll_dice(6)
Why isnt it possible to write the code in that way …
print "the maximum possible value is %d" % max_val
if get_user_guess > max_val:
print "u stupid idiot. U should guess a number less than or equal to 12“
… or …
print "the maximum possible value is %d" % max_val
if get_user_guess() > max_val:
print "u stupid idiot. U should guess a number less than or equal to 12"
Das wuerde doch ne komplette Zeile einsparen und trotzdem alle Infos beinhalten? T-T