Check Yourself!


4. Check Yourself!

I'm trying to get the variable to print out because it passes the if conditional.

Oops, try again. The original variable ("hey ") had more than 0 characters but did not get printed.

I was trying to get my output to be the word that the user would have input.
For example: user would input: "Hello!" and would print this from my variable original

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word:")

def word_confirmation():
    if len(original)> 0:
        print original
        print "empty"


This is not called for nor expected. Write the code as global inline code.


you're not calling the function word_confirmation() so none of the code in the function is happening
I suggest getting rid of the function altogether though, and just using the code inside of it because the instructions don't ask you to use a function


THANK YOU SO MUCH! I appreciate it! I deleted the lines and fixed my indentations and everything worked exactly as planned!


Quick question on top of that!

I moved to the next step and added isalpha() to it - the code then proves to be a false statement if the word has a space in it... is there any global functions that I can access to change that so that it will pass this or no?


Space characters are not alpha, which means we can only pass in a single word. To allow spaces we would need to introduce more logic.

if len(original) > 0:
    test = original.split();
    for word in test:
        flag = true if word.isalpha()
    if flag:
        # code


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