Jump to content

OMG codecadamy is so bad using python

jameshumphries47

okay guys so you probably know im learning python and im having problems codecadmay is horrendous 

for example here is what im working on 

pyg = 'ay'
 
original = raw_input('Enter a word:')
word = original.lower()
 
 
if len(original) > 0 and original.isalpha():
  word = original.lower()
  first = original[0]
  new_word = word + first + pyg 
  new_word = new_word[1:len(new_word)]
 
  print new_word 
 
 
else:
    print 'empty'
 

right im getting an invalid syntax on the else line... HOW! grr 

im sorry to bug everyone for a second time but here please help

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know if that code is wrong, but I've encountered a few bugs on Codecademy. Try it out using the standard IDLE and see if it works.

Link to comment
Share on other sites

Link to post
Share on other sites

I'm going to go out on a limb and say that your code is invalid because your 5th and 6th non-whitespace lines need to be indented (so the indent shouldn't stop until the else). IIRC, python is weird in that formatting is key, so that is likely to be your issue. I'm no expert though, and have only briefly looked at python.

EDIT: the OP appears to have been changed now, which would make my observation invalid.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

Which exercise is that? I've finished that course so I can go back and get my code for you. Sometimes on Codecademy there's glitches where things that should work, don't, or that you don't match the output exactly.

"Everybody wants a happy ending, right? But it doesn’t always roll that way." - TS

 

Link to comment
Share on other sites

Link to post
Share on other sites

---

---

i copypasted your exact code at that exact link and the program runs fine

try to type it in manually again to be sure that there is no weird character hidden somewhere

Link to comment
Share on other sites

Link to post
Share on other sites

Which exercise is that? I've finished that course so I can go back and get my code for you. Sometimes on Codecademy there's glitches where things that should work, don't, or that you don't match the output exactly.

dont worry i fixed it :) thank you though 

its this 

print "welcome to the pyg latin translor!"pyg = 'ay'original = raw_input('Enter a word:')#turning it into all lower case!word = original.lower()#making that there are more than 0 chars typed in and its lettersif len(original) > 0 and original.isalpha():  word = original.lower()  first = original[0]  new_word = word + first + pyg   new_word = new_word[1:len(new_word)]    print new_word  else:    print 'empty'

Check out my current projects: Selling site (Click Here)

If($reply == "for me to see"){

   $action = "Quote me!";

}else{

   $action = "Leave me alone!";

}

Link to comment
Share on other sites

Link to post
Share on other sites

i copypasted your exact code at that exact link and the program runs fine

try to type it in manually again to be sure that there is no weird character hidden somewhere

He fixed it. it was broken before.

Link to comment
Share on other sites

Link to post
Share on other sites

Python is very sensitive to how you indent your code.

In your second example, the print in else statement is more indented than the if block. This shouldn't be an issue, but using combinations of spaces and tabs can cause issues from time to time.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×