Code does not recognize Full Names


This isn't a problem with the coding, more so a loophole in the directions. In PygLatin Part 1, it tells you to use .isalpha() to check if the user inputs a real word without any non-letter characters. It works if you input your first name only, but when inputting two names with a space separating them, the if statement is false and it prints "empty". I solved this by adding or original.find(' ') after the .isalpha(), however it doesn't allow you to proceed and shows "Oops, try again. It looks like your code prints original ("Tom Cruise") when original includes non-alphabetical characters." Again, I know how to proceed through the exercise; I'm just pointing out a loophole.

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("What's your name?")

if len(original) > 0 and original.isalpha() or original.find(' '):
    print original

    print "empty"


space is a non-letter character? So the instructions are fine?


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