Help with check yourself


#1

Hi. This is my code. I have had trouble for a while:

print 'Welcome to the Pig Latin Translator!'
original = raw_input("Enter a word:")
if len(original)>0:
    print original 
    else;
        print "empty"

The error comes up as:
Your code looks a bit off. Check the Hint if you need help!

I checked the hint section and it hints to use the ">" symbol. I obviously am using the > symbol in the third line.

Apparently there is something wrong with line 5 as well which would be the "else:" line.... it says it is an invalid syntax. I don't know what is wrong with line 5. It looks correct, unless if I am missing something.
Help please. Thanks in advance.


#2

it looks like your else is indented too much. Put it in line with the if section. Also, make sure to use a : not a ;.


#3

I figured that out. Thanks. Does it really matter about indenting that much that the whole system will go crazy if your else or print isn't indented properly?


#4

Yeah man, else; would be a statment, but what you really want is else (statement);


#5

I am pretty sure indentation does not matter, I am not aware of a compiler that reads most white space. indentation is usually for us hoomans :stuck_out_tongue:


#6

In other languages, indentation just helps make it more readable.

In Python indentation does matter. If you're familiar with javascript, indentation is basically the equivalent of javascript's brackets. Here's a video that explains it better.

Also, from what I've read python isn't necessarily a compiled language. You can compile it to make it more efficient, but generally it's not. I'm a noob though so that's just what i've read :stuck_out_tongue_winking_eye:


#7

oh cool! :stuck_out_tongue: yeah I have no experience with python, I am mainly into C. Learn something new every day


#8

Nice! Where'd you learn C? I need to find place to learn that lol


#9

Lol, I am a uni student :stuck_out_tongue: C is great. once you learn C, you will abandon your love for Java (if you have any lol)