PygLatin code works, but Codecademy won't accept it?


#1

Hello everyone,

Below is the code I am using and as mentioned in the title it works as it should, however Codecademy continues to say "The original variable ("word_I_entered") had more than 0 characters but did not get printed." Which the word does get printed. I believe everything looks correct can someone see if they can figure out what I did wrong. Thank you so much :slight_smile:


def PigLatin():

    print 'Welcome to the Pig Latin Translator!'

    original = raw_input("Enter a word: ")

    if len(original) > 0:
        print "We will now convert the word %s." % (original)
    
    else:
        print "empty"
        
PigLatin()

#2

remove the function, it causes problem for the exercise to validate. as for your print if the input is valid, just print original, no additional string, this also causes problem for the validation.


#3

Yea that worked thanks I changed my code to,

print 'Welcome to the Pig Latin Translator!'

original = raw_input("Enter a word: ")

if len(original) > 0:
print original

else:
print "empty"


It worked that time so maybe I was making it too complicated, thanks again stetim94!


#4

sometimes adding additional code can cause problems, just try to do what the exercise tells you to do, if you want to experiment, install python on your computer


#5

Hi @dragon.air ,

Codecademy's submission correctness test (SCT) for the PygLatin exercises examines the values of variables, but it is only designed to look at global ones. Therefore, if you enclose the scope of certain variables inside a function, the SCT does not find them. While encapsulating the details of a game inside a function is often a great idea, it causes problems within the context of this particular set of Codecademy exercises.


#6

Oh ok, thank you for the reply I guess we can close this thread now, everything is resolved :slight_smile:


#7