python 第四例

import random
num = random.randint(1,100)
running = True

while running:
    answer = int(input('guess(1-100):'))
    if answer > num:
        print("猜大了")
    elif answer < num:
         print("猜小了")
    else: 
        print("猜对了") 
        running =False
 

你可能感兴趣的:(Python初级挑战高级)