4. Check Yourself - prints empty as well as raw input


#1



4. Check Yourself


It doesn't come up with an error message but running the code prints both the raw input value as well as "empty". Is this supposed to happen? I can't see anything wrong with my code.


print 'Welcome to the Pig Latin Translator!'

raw_input("Enter a word:")
original = raw_input()

if len(original) > 0:
    print (original)
else:
    print "empty"


#2

this line is the problem,

because this,

Should be stored in the variable original like so,

original = raw_input("Enter a word: ")
#Note: I added a space after Enter a word: and the closing parentheses"

#3

Awesome, thanks for that. That works and has solved my problem.

Just for my understanding, why can you not assign the raw input as to the variable after the raw_input() function has been set?


#4

Because it is like setting the variable original to an empty raw_input


#5

Okay that makes sense, thanks for your help!


#6

You're welcome :grin: if that was the answer you were looking for feel free to click the solution button below my reply. :slight_smile:


#7

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