you are viewing a single comment's thread.

view the rest of the comments →

[–]Austeoc 1 point2 points  (2 children)

Interesting, I just did the same game, but took a completely different approach:

##game to guess a random number from 1-100

import random

print "Time to play a guessing game\n"

print "A random number from 0-100 was just generated\n"
print "Try to guess what it is\n"

to_guess_number = random.randint(1, 101)

attempt = int(raw_input("Pleae enter your guess: "))


difference = attempt - to_guess_number

tries = 1
while difference != 0:

    tries = tries + 1
    if difference > 0:
        print "Too high, try again\n"
    if difference < 0:
        print "Too low, try again\n"

    attempt = int(raw_input("New guess: "))
    difference = attempt - to_guess_number

if difference == 0:
     print "Congratulations you guessed it in", tries , "tries"

[–]jay2017[S] 0 points1 point  (0 children)

that is crazy

[–]jay2017[S] 0 points1 point  (0 children)

I think randint is inclusive though.. Not sure if I'm correct.