ค้นหาบล็อกนี้

วันเสาร์ที่ 13 พฤศจิกายน พ.ศ. 2553

คำตอบข้อแรก

credit = int(input("Input credit: "))
LOWEST = 1
HIGHEST = 100
B = credit
A = count
while A < B:
    count = count + 1
    if count > credit:
        print("Game over! The solution is %s!" % (answer))
        break
    guess = int(input('[%d/%d] Guess the number between %d-%d: ' % (count, B, LOWEST, HIGHEST)))
    if guess > answer:
        print("Too high")
        HIGHEST = guess - 1
    if guess < answer:
        print("Too low")
        LOWEST = guess + 1
    if guess == answer:
        print("Correct answer!")
        print("You guessed",count,"times.")
        break

ไม่มีความคิดเห็น:

แสดงความคิดเห็น