Python PygLatin


#1

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
    new_word[1:len(new_word)]
    print new_word[1:]
    
    
else:
    print 'empty'

#2

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.


#3

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


#4

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


#5

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.


#6

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


#7

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


#8

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:


#9

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