Pyg Latin


#1

why doesn't why code work?

Replace this line with your code. 
pyg = 'ay'

original = raw_input('Enter a word:')

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

#2

Hi @systemace03874 ,

You are attempting a slice here ...

new_word = [1:len(new_word)]

However, prior to the square brackets, you need to specify what to slice.


#3

how should I do that?


#4

What object would you like to slice?


#5

I need to slice the new_word slice


#6

Place new_word just prior to the opening square bracket. Then post the new version of your code, if it still does not pass, so that we can address additional problems.


#7

like this ???
pyg = 'ay'

original = raw_input('Enter a word:')

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


#8

I don't think that is what you meant...


#9

Actually, this ...

new_word [1:len(new_word)]

... should be ...

new_word = new_word[1:len(new_word)]

So, fix that and check your code again.


#10

Isn't working here is the error message
Traceback (most recent call last):
File "python", line 8, in
NameError: name 'new_word' is not defined

pyg = 'ay'

original = raw_input('Enter a word:')

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


#11

Remember to format code when you post it. See How do I format code in my posts?.

The problem is that you have not defined new_word before attempting to slice it. The instructions ask you to perform a concatenation to do that. It should be placed after ...

first=word[0]

... and should look like this ...

new_word = word + first + pyg

Then, you can slice it. After fixing that, check your code again and post it, if necessary, so that we can address any remaining problems.


#12

It finally worked thank you so much!!!


#13