Will not execute. What am I missing?


#1

Here is my code, when I run the code it works but must set new_word.
pyg = 'ay'
original = raw_input('Enter a word:')
word=original.lower()
first=word[0]
if len(original) > 0 and original.isalpha():
print original
new_word = word + first + pyg
new_word [1:len(new_word)]
print new_word[1:len(new_word)]
else:
print 'empty'

After I fix the code to:
pyg = 'ay'
original = raw_input('Enter a word:')
word=original.lower()
first=word[0]
if len(original) > 0 and original.isalpha():
print original
new_word = word + first + pyg
new_word = [1:len(new_word)]
print new_word[1:len(new_word)]
else:
print 'empty'

It will not execute. What am I missing?


Ending up Pyg Latin
#2

here:

new_word = [1:len(new_word)]

you forgot to take a slice of new_word:

new_word = new_word[1:len(new_word)]

that is why it is not working


#3

This line should be right after the input so the validation takes place before anything else. Remove the line, print original as it is no longer needed.


#4

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