5 Ocak 2014 Pazar

Number Guessing Game in Python


import random
answer=random.randrange(1000,10000)

while True:
    choice=int(raw_input('Enter a number:'))
    if choice<1000 or choice>9999:
        print ("Enter a number between 1000 and 9999:")
    elif choice<answer:
        print("Too low")

    elif choice>answer:
        print("Too high")
    elif choice==answer:
        break
print ("You got it")
s

2 yorum: