python 3作业错误

时间:2017-07-28 16:00:57

标签: python python-3.x compiler-errors

我在python 3上做了一个功课,使用if,elif,else,.isdigit,.isalpha,但我不知道为什么它不起作用..

NumWord = ""

def str_analysis():
    if NumWord.isalpha() == True:
        print(NumWord, "is all alphabetical characters!")
    elif NumWord.isdigit() == True:
        if int(NumWord) == 100:
            print("You found the right number!")
        elif int(NumWord) >= 99:
            print(NumWord, "is a pretty big number")
        elif int(NumWord) <= 99:
            print(NumWord, "is a smaller number than expected")

while NumWord.isalnum() == False:
    NumWord = input("Enter a word or integer: ")

1 个答案:

答案 0 :(得分:2)

你需要实际调用你写的函数:

while NumWord.isalnum() == False:
    NumWord = input("Enter a word or integer: ")
str_analysis()