Pyglatin: Ending Up


#1

pyg = 'ay'

print 'Welcome to the Pig Latin Translator!'

Start coding here!

pig_latin = raw_input("Enter a word:")
original = pig_latin
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
new_word = word + first + pyg

print new_word[1:]

else:
print "You did not enter anything or remove your number"

This comes out correctly in the console but an error message pops up and says "It looks like you printed the correct translation of 'food', but make sure to set new_word equal to the slice as well." I don't understand what it wants me to do.


#2

@kltkat,
The instruction:

  • 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.

you will have to add the code

new_word=new_word[1:len(new_word)]

#3

I am having a similar issue. I have made it thus far without getting stuck, but now I need assistance.
For some reason I can't slice the first letter and move it to the end of the word.
[FIXED]

if the image doesn't load this is what my input looks like

pyg = 'ay'

original = raw_input('Enter a word:')

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

[My code is properly indented, app doesn't show my indent once I save message]

I still get oops try again looks like new_word contains "finallyay" instead of "inallyfay"

Ok, after a while longer looking at the faqs I found a solution. 1st off the format of my

new_word = first + word + pyg was off by
new_word = word + first + pyg simply switching those 2 words around.i sovled my 1st letter to the end issue. 2nd setting new_word to

new_word = new_word[1:len(new_word)]

I then created a new variable 's' to equal new word and printed s

my code ended up looking like this

pyg = 'ay'

original = raw_input('Enter a word:')

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


#4

I don't understand why this returns the error:

"The value for the original variable looks off, make sure that you entered a word containing only letters"

new_word = "Charlie"
print new_word[1:len(new_word)]

the 'l' in string is el not one.

Anyone know what might be the problem?


#5

what section are you on and what are you trying to get the code to do? Can you post the whole code?