In Pop Quiz! I don't get the answer I expected


After "Enter a word:" I typed "hello guys".

No error messages, but the terminal printed "empty", while I expected it to print "hello guys", because it satisfies the if condition: its length is > 0 and it only contains alphabetical characters.
I thought that maybe this is due to the fact that I entered to words instead of one, and the space is counted as a non-alphabetical character, am I right?

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word:")

if len(original) > 0 and original.isalpha():
    print original
    print "empty"


a space is not a alphanumeric character


Thanks! I suspected it.


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