Python PygLatin


I have read other topics and am still unable to figure out what I am doing wrong. I have included my code below and would love the input!!

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

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


You're not storing this anywhere...You need to store this in new_word.

That [1:] is not needed here. You'll be slicing too much.


What do you mean by storing new_word[1:len(new_word)]? Thank you for your input! I greatly appreciate it!


Taking an example from your code:

You are storing word[0] into the variable called first.
Now, store new_word[1:len(new_word)] into new_word because just new_word[1:len(new_word)] alone isn't going to do anything (Do this after new_word = word + first + pyg).


Ok that makes sense. Thank you! One more question if you don't mind. I did what you said and when I entered "hello" into the program, it returned "llohay". It should return "elloyhay" correct? It let me pass but I would like to make sure I am doing this 100% correct.


I've already addressed this. It's supposed to print "ellohay". You sliced too much.


That fixed it!! I'm so sorry for wasting your time. Thanks


No need to be sorry for wasting my time. I'm allocating it to helping people so I will never consider it wasted.
And no problem! Have a great day :slight_smile:


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