Oops, try again. It looks like new_word contains "originaloa" instead of "riginaloay"!

i wish you guys could help me so it could print out "riginaloay"! ,

pyg = 'ay'

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


Put these three lines inside the if- block ( do not forget to indent)
also its not pyg[0] but just pyg ?

also check your if's test.. len(original) > 1 ,length should be greater than 0, as if it has length of 1, your current code will return 'empty' which is wrong?

also you need to do what it says in final exercise..

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.


I tried using this code and it worked:

Spoiler (click to view)

pyg = 'ay'

original = raw_input('Enter a Word:')

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


@hodgejo2016, this compiles but it is not how PygLatin works, for example:

If you input "baseball", PygLatin should = "aseballbay"

Using your code:
If you input "baseball", you get "seballbay"

This is because in print new_word[1:len(new_word)] you are chopping off an additional "first" letter. Speaking strictly in terms of errors, your code does not contain any errors and that's why it compiles! :slight_smile:


Instead should be like this:
new_word = original[1: len(word)] + first + pyg


hello @codefolk
It could be but I think the CC will create some error (?).
I just tested with that code and It lets me pass (but I doubt as I already passed this exercise so It might be "just" letting me pass the exercise?).

I'd say try that and check for yourself if it works or not.
(that line of code is okay and will work in normal cases but here on CC, sometimes it turns out we need to follow exact instructions.)


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