Reputation: 107
I have a homework on python 3 to do, using if, elif, else, .isdigit, .isalpha but i dont know why it doesn't work..
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: ")
Upvotes: 0
Views: 159
Reputation: 92440
You need to actually call the function you wrote:
while NumWord.isalnum() == False:
NumWord = input("Enter a word or integer: ")
str_analysis()
Upvotes: 3