The "empty" output is wrong


#1

After you add the isalpha() check, you would still get "empty" error when you are using a non-empty string that has non-letter characters. A better option would be to change it to something like "invalid" or "not a word"


#2

Hi, @balinc ,

Agreed. Though the following if-else structure departs from the instructions, it works ...

if len(original) > 0:
    if original.isalpha():
        print original
    else:
        print "invalid word"
else:
    print "empty"

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.