Clarification Python (Check Yourself)


So my code passes and it says proceed to the next lesson, but what I don't understand is why it asks me to "Enter a word:" twice in the output. Even if I enter two different words, the code runs, and it asks me to proceed to the next lesson.

My output
Welcome to the Pig Latin Translator!
Enter a word: dragon
Enter a word: drag

I was expecting it to ask me to enter the word only once, and after I hit enter, it would print the word I have entered, and if I leave it blank, for it to print "empty" instead of me having to hit enter twice to get the "empty" message.

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
raw_input("Enter a word:")
original = raw_input('Enter a word:')
if len(original) > 0:
    print original
    print "empty"


That line may be removed. It is not a complete statement and does nothing.


Yes, it works properly then. Thank you! I was wondering because it was a part of the code provided when the lesson started.:smiley:


I've been wondering why we see this error so often. Going forward, just be sure that each line is a complete statement. If it is just an expression,


a == 42

b + 6

and so on, it is not a statement and parsed or not, nothing is preserved or acted upon.


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