num = input('用户请输入电话号')
if not num.isdigit():
    print('你输入的不是数字')

else:
    if len(num) != 11
        print(输入不正确)

    else:
        tel = num[:3]
        if 130<= int(tel) <=150:

        # if 130<=tel<=150:     # Str和int比较前必须转为int, 否则报错!!!
            print('这是移动号')

        elif 150<= int(tel) <=170:
        # elif 150<=tel<=170:
            print('这是联通号')

        elif 170<= int(tel) <=199:
        # elif 170<=tel<=199:
            print('这是电信号')

        else:
            print('该手机号不属于任何运营商')


↙↙↙阅读原文可查看相关链接,并与作者交流