Pyg Latin 6 - 10: Wrong Instruction?


#1

Hi there,

I don't know if I understand the instruction correctly, but from my point of view it looks wrong, concerning the correct soultion I found. The instruction says:

Set new_word equal to the slice from the 1st index all the way to the end of new_word. Use [1:len(new_word)] to do this.

But instead it has to be:

Set new_word equal to the slice from the 1st index all the way to the end of word. Use [1:len(word)] to do this.

I don't like to spoil the solution code, so please just relation on an example input:

Enter a word: no
no

Oops, try again.
It looks like new_word contains "daynay" instead of "onay"!

pyg = "ay" SOLUTION: "####ay"
first = "n" SOLUTION: "###nay"
new_word[1:] = "ay" SOLUTION: "#aynay"

maybe someone can explain me where the "d" comes from?

I really like the project!
Go on!


#2

We can do this both ways, with word or with new_word. Just the order is slightly different.

first = word[0]
new_word = word[1:] + first + pyg

or

first = word[0]
new_word = word + first + pyg
new_word = new_word[1:]

Either way, the first letter is lobbed off.


#3

Hi mtf!

I understand. You got me :smiley:
But what about the "d" in the wrong output?

Thanks


#4

I didn't test that. Will go do it now.

Edit. My code is correct so gives, onay to no. I will need your oiginal code to test, if you still have it.


#5

That was my code:

pyg = 'ay'

original = raw_input('Enter a word:')
word = original.lower()
first = word[0]

new_word = new_word[1:] + first + pyg

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

Now I receive:

Enter a word: no
Traceback (most recent call last):
  File "python", line 7, in <module>
NameError: name 'new_word' is not defined

before that worked :wink:
Maybe there was something in my cache?


#6

This is not defined yet. Declare the variable,

new_word = word + first + pyg

Then slice the new_word.


#7

I know. But somehow it worked before instead of giving me the error! So never mind.

In another lesson i found an Instruction with

Change the body of ...

I assume you want to provide more than one solution and still be able to validate the code.
So isn't there a slightly difference between "set", "reset" and "change"
Like:

Add a new line ...

Why do not state different possibilities of instructions to solve the problem and show that there is more than one solution?


#8

Please direct your suggestions to the Codecademy staff by posting in the Platform subcategory of the CC community lounge. Also, please include a link to the lesson. Thank you..


#9

I really like the project. I will do so!

Thank you!


Show more than one code solution by multiple instructions
#10

A post was split to a new topic: Did you accidentally delete the first variable? who can tell me why?


#12