Check yourself


Tried the below, but it doesn't work. Regardless of what I type, the output always comes back as "empty". So even if there is a word in the console, it will come out as the "else" function....but the lesson says I did it right, even though it's not doing what I think I'm asking?

print 'Welcome to the Pig Latin Translator!'

raw_input ("Enter a word:")

original = raw_input
empty_string = ""

if len(empty_string) > 0:
print original

print "empty"

PygLatin Check Youself

you should prompt the user for input using raw_input, then store the result of this prompt into original, this should be accomplished in a single line of code.

what do you need empty_string for? Once you fixed your raw_input, you can use original in the if condition


If I remove the empty string line of code (which was use as an example in the lesson), and type the below code, then it says there is something with the if code.

print 'Welcome to the Pig Latin Translator!'
raw_input ("Enter a word:")

original = raw_input

if len(original) > 0:
print original

print "empty"


that was 50% of my answer, here is the other 50%:


original = raw_input

you call raw_input for the second time (without parentheses), storing a function object in original, yes, that will cause errors in if condition.

why do you need raw_input twice? The user only needs to enter one word

raw_input is a built in function, calling functions requires parentheses (unless you want the function object, but i can't imagine why)


Ahhh I see what you're trying to say now. I thought you needed to separately assign the "original" value to raw input after having written the raw input code. The lesson doesn't really explain that this needs to be done, and I have seen others with the same issue, but they also include the "empty_string" command too.

Anyway, thanks! It works now.


no, original is just a variable in which we store the result of calling raw_input()

so instead of storing a string in original directly:

original = "translate"

we ask the user to store a word of there choice by using raw_input (raw_input is just a function which allows us to prompt the user)


for x in range(1,len(word)):
print word[x],
print word[0]+' a y'

That's the code what I have thought but still I get spacing in between the letters in the output the interpreter gives.
Otherwise according to me everything else goes right.


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