Problem with PigLatin


#1



https://www.codecademy.com/en/courses/python-beginner-2W5v7/1/4?curriculum_id=4f89dab3d788890003000096


File "python", line 11
new_word=[1:len(new_word)]
^
SyntaxError: invalid syntax
It keeps on giving me an error message and I'm not sure what to do.


I expect it to run correctly. Giving me a raw input ,and than slicing off the first index and adding ay at the back of the 'new word'


pyg = 'ay'

original = raw_input('Enter a word:')

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


#2

If you want the second item on the shelf, then it's not sufficent to say "the second item", instead you would need to say "the second item on the shelf", same goes for slicing, you have to say what you're slicing


#3

Oh OK sorry. This is kind of my first time coding or learning a programming language.So I am quite familiar with certain terms.
I meant that once I type out the word in the counsel eg. Cat .The first letter was sliced off, and than added at the back of the remaining word and 'ay' was also added e.g. new_word =word+first +pyg.


#4

I was referring to your code
The exercise is about slicing
You're slicing some value
But you're not specifying which value, which makes it nonsense - syntax error

From the second to the end
...of what?


#5

Ok but when its raw input doesn't it mean that I should enter the as you said value or word into the counsel.And then I save it by the variable original .


#6

Still just the slicing. See the line number in your syntax error. You have a start index and a stop index, but nowhere does it say which value is to be sliced, what you've written doesn't match anything that python recognizes. Compare to the example(s) in the instructions


#7

Thank you for making it clear.


#8

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