PygLatin "Ending Up"


#1

Hi folks,

I've been staring at the same bit of code for a week and I'm just about to go bonkers. It is the python translator, and I cannot seem to generate an adequate program to operate the translator. Can someone please advise? Code is pasted below.

pyg = 'ay'

original = raw_input('Enter a word:')

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

#2

Can you paste your code with 3 backticks ( which look like this ` ) on both ends?


#3

@dantemp, i inserted the back-ticks. I will leave it to you to help netace, good luck


#4

        new_word = word[1:len(new_word)] + first + pyg
        print new_word

new_word_1 was just new_word. What I did was grab everything from word, except for the first letter, rather than just the first letter, then deleted the unnecessary new_word_1.


#5

@netace11543 Hope this works

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:]
print new_word[1:]
print new_word

else:
print 'empty'

Your 6th and 7th line of code is causing error., coz word[1] will only print 2nd word of original.


#6

In that line, you must replace word[1] for word[1:]


#7