PgyLatin: what is wrong with this code


#1

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

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


#2

Hi all this part

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

should be inside the if statement you don't neeed of this line

word = "Kuloski"

#3

File "python", line 10
new_word = [1:len(new_word)]
^
SyntaxError: invalid syntax

that is the error code i am facing


#4

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

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

you said word = "Kuloski" is not needed right? i remove the unneeded and still got same error message


#5

Yes remove it

word = "Kuloski"

then here

new_word = [1:len(new_word)]

with this [1:len(new_word)] you want to slice new_word so you should put it like that

new_word = new_word[1:len(new_word)]

then inside the if statement at then of it put

....
    print new_word
else:
    print 'empty'

#6

thanks. it worked. over a month trying to solve this part myself. i guess the instruction they gave to do this is mixed up or i dont get it clearly. thanks


#7

They should add to the instructions that you need to:

replace or add:

print original

with or after:

print new_word

They should also add an error message with "Oops! Did you remember to print new_word to the console?" or something. My program wasn't working correctly either (wasn't PygLatin-ifying my input words), even though it was letting me press Next after submitting my code and claiming that I now should have a "fully functioning Pig [sic] Latin translator", so I was very confused.
Unfortunately, there seems to be no "report a bug" on this exercise.


#8

true. got so many of such aylmarianna


#9

i did passed this code but i don understand the result. please can you help me out.