Ending up


#1

below is my script

pyg = 'ay'

original = raw_input('Enter a word:')
word = original.lower()

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

the error that I receive is that i need to set new_word equal to the slice as well. I'm confused and any assistance would be appreciated


Ending up
#2

What I think they mean is that now you are doing the slicing in the print statement. Maybe they want you to to save the slice in the variable first like so:

new_word = new_word[1:len(new_word)]

And then just print that variable

print new_word

#3

I was having the same problem, and this worked! Thanks! weirdly worded instructions for that lesson.


#4

I dont get why this works...


#5

It's just because codecademy want it this way. The way the original poster wrote the code does exactky the same


#6

yes it works but the instructions give you different directions i understand that there are several ways to complete a single task in python but this is just not what the instructions said and they need to go back and fix those instructions


#7

This was confusing.
What about the fact that we had to erase the old new_word variable?
How is it calculating this? -____-


#8

Great, even more confusing.
I entered word Ham
Pig Latin Translation: rdbay
Then it said Congratulations.
How is this correct???


#9

I agree - the instructions are little vague with some minor (yet important) steps missing. A little more detail would go along way.


#11

This lesson seems to be buggy. I will share my experience in case it helps the community:

First, here is my code (cross-checking purposes only of course!):


pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
print original
else:
print 'empty'

word = original.lower()
letter = word[0]

new_word = word + letter + pyg

new_word = new_word[1:len(new_word)]

print "Your original word in Piglatin is %s." % (new_word)


First:

I tried around 15 variations in my code before the trainer would allow me to move on, DESPITE the fact that my code itself was working fine.

(As in, the code itself would run, and it successfully acted as a piglatin translator for any word I would input. The website trainer however would not allow me to continue.)

Second:

For certain, specific words that I would input for the program to translate, the trainer would tell me:
"Oops, try again. first should contain the first letter of word."

Words it would reject include "Mountain, farm," and anything other than the words "Type" or "toilet".

Third:

For the words "type/toilet", it would report: "Way to Go! (start next lesson)"

I will also note that I am LUCKY to have found those words as ones the trainer accepts, because no other words (even other 4 letter words) that I have yet tried seem to be OK with the trainer!

The main points I would summarize are:
My code worked as a pig latin translator for any input word, and does run.

The website trainer however, would only allow me to move on to the next lesson when I input the words "type" or "toilet" into the translator. It rejected all other attempted inputs.

The trainer would return its "Way to Go!" and "Error" messages intermittently, without me changing any of the actual code. The message the trainer returned appeared to be totally dependent on whether or not I entered the word "type/toilet" into the already-running piglatin translator.

I invite corroboration from my fellow users to confirm my results using the above code, and the administrators to correct these errors (if it is an issue with the program).

Hope this helps!


#12

@justindluffy I tried that and it didn't work, do you recommend trying something else?


#13

here is what I'm doing:

pyg = 'ay'

original = raw_input('Enter a word:')
o = "original"
if len(original) > 0 and original.isalpha():

print o

print o[1:7]

else:
print 'empty'

word = original.lower()
letter = word[0]

new_word = word + letter + pyg

new_word = new_word[1:len(original)]

print "Your original word in Piglatin is %s." % (original)

What am I doing wrong @justindluffy?


#14

Honestly I'm not sure. I would start by making sure that the indentations are correctly placed for your if - else: statements. It's finicky that way.

Also, there is a bit of an error when you defined o = "original". See, all that did was to store the WORD "original" as a string in variable o. Python doesn't understand that you meant to reassign the "o" variable to the raw_input from the user.

It doesn't see a connection between the WORD "original" and the fact that you assigned the variable original to a different variable. That's because original is in quotes, so its not the name of a variable anymore but a string.

But like I said, I am not sure because I'm really new at this too!
. I would recommend maybe starting at the beginning of the pyglatin translator lessons and doing everything EXACTLY as they wrote? (I added the -print "Your original word in Piglatin is %s." % (original) - just as some extra code to pretty-up the translator, i.e. it is totally unnecessary and may be causing the interpreter problems... idk.)

Best of luck to you though, and I'm sorry I couldn't be of more help!


#15

The code:

pyg = 'ay'

original = raw_input('Enter a word:')

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


#16

Thank you. This code actually helped me!


#17

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