py猜数字游戏

#coding:utf-8

import random

number=random.randint(1,100)

while True:

    num_input=input("请输入数字:")

    if not num_input.isdigit():#判断输入的是否为数字!

        print("请输入数字!")

    elif int(num_input)<0 or int(num_input)>=100:

        print("请输入0到100的整数")

    else:

        if number==int(num_input):

            print("OK")

            break

        elif number>int(num_input):

            print("小了")

        elif number

            print("大了")

你可能感兴趣的:(python学习)