Help with Check Yourself!


#1


I dont know what i did wrong. I keep getting this error.

https://www.codecademy.com/courses/python-beginner-2W5v7/0/4?curriculum_id=4f89dab3d788890003000096#

File "python", line 5
if l(original)>0:
^
IndentationError: unexpected indent

Oops, try again. Oops! Did you accidentally delete the variable called original?


original=raw_input("Enter a word")
    if len(original)>0:
    print original
    else:
    print "empty"


#2

You were suppose to check if the length of the variable "original" is greater than zero. Did you mean this?

 if len(original) > 0:

#3

My code is:

original=raw_input("Enter a word:")
if len(original)>0:
print original
else:
print "empty"
I am getting error with the else statement.It is showing me
File "python", line 7
else:
^
SyntaxError: invalid syntax


#4

This happened to me too. I had to first store the value of len(original) into a variable (number = len(original)) then put that variable into the if statement. I dont know if that is the proper way to do it but it worked. heres my exact code if you want it.

print 'Welcome to the Pig Latin Translator!'
print 'please type a word.'
original = raw_input()
number = len(original)
if number > 0:
print original
else:
print 'empty'


#5

yes! but i am still getting the same error


#6

It is still not working


#7

I have the same problem. It gives me an error message. I tried it without defining len(original) as number, with my if statement just "if len(original)>0" but that didn't work either. thoughts??

print 'Welcome to the Pig Latin Translator!'

Start coding here!

raw_input ("Enter a word:")
original = raw_input
number = len(original)
if number > 0:
print original
else:
print "empty"


#8

You have wrong indents. Your print statements should be one indent after your if, else statements.


#9

Looking at the error message I think that he should just decrease indentation of if and else:

original = raw_input("Give me a word!")
if len(original)>0:
    print original
else:
    print "empty"

#10

Yes, I tried this and it worked! Thank you so much!


#11

Whoops! Wasn't paying close attention. :sweat_smile:Sorry about that. :slight_smile:


#12

You're very welcome :slight_smile:


#13

I did actually indent but it still doesn't work :sob:


#14

Did you indent the way @factoradic said? If you still have a problem after that, then please show your current code and error message?


#15

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