Check Yourself!


#1

print 'Welcome to the Pig Latin Translator!'

if len(original > 0):
else:
print "empty"
original = raw_input("enter here")

Not sure what is wrong with this one. :confused:
please help


#2

@designsolver87762

Try it with a bit changed/updated

print 'Welcome to the Pig Latin Translator!'
original = raw_input("enter here")

if len(original > 0):
    # 4 space's indentation
    print original 
else:
    # 4 space's indentation
    print "empty"

#3

weird. i tried using your code in the if line but still display error but when i put it out of the racket like this
if len(original) > 0:
it was accepted to proceed next exercise :confused:


#4

@designsolver87762 The original line should go right under the first print statement, not the bottom. This is because the if statement and everything else revolves around the user's input. Also you might want to check this:

What happens if the length of original is greater than zero? By the instructions, then you should be printing original. If you do all that then your code should look like this:

print 'Welcome to the Pig Latin Translator!'

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

Hope that helps! Let me know if you still need more help. Good luck and happy coding! :slight_smile:

-- @chipjumper36731


#5

@n3thead Can you show me you entire code so I can help you?

-- @chipjumper36731


#6

another thing, i know nothing about computer language, i learn python for fun. do u know what is len stand for in
if len() : i mean def stand for define right then this len stand for what ? thanks for ur help


#7

Here len means 'length'


We used it for String(ie.The content between " “)


One example: len(hello) == 5 // Because hello has 5 characters


Hope it will help you


#8

i see. now it s more clear when you give that example. Thank you @lealcode :slight_smile:


#9

@n3thead That's okay I learn coding for fun as well. The function len stands for length. It checks the length of a list, string, etc. or how long it is. So in the line:

if len(original) > 0:

Your function is checking if the length of the user's input a.k.a the variable original has more characters than zero, which basically means it is making sure the user didn't enter a blank statement. For more information about len you can go here:

Len Functions in Python

Also, I don't quite see anything wrong with your code, except for original line. You see, Codecademy only has a certain number of ways they will accept the code regardless if the other way is right or not, and the original statement may be the problem, because they do not recognize that way. Go ahead and replace your original variable line with mine:

original= raw_input("Enter a word:")

Ultimately your code will look like this:

print 'Welcome to the Pig Latin Translator!'

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

Hope that help! Let me know if you need more help. Good luck and happy coding! :slight_smile:

-- @chipjumper36731


#10

yeah i changed the default line. Thanks for the help. Appreciated it :relaxed:


#11

Anytime :slight_smile: Glad to help! Keep coding!


#12

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