Correct code but getting a syntax error


<Below this line, add a link to the EXACT exercise that you are stuck at.>
10/11 Pyglatin Ending Up

<In what way does your code behave incorrectly? Include ALL error messages.>
I get this error message while it’s considered as a pass.
File “python”, line 9
final_word = [1:len(new_word)]
SyntaxError: invalid syntax

<What do you expect to happen instead?>
A fail as the program encountered an error

pyg = 'ay'

original = raw_input('Enter a word:')

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


You need to specify a list/variable containing a list you want a slice of before the square brackets, how else is python suppose to know what to take a slice of?


Hi @blogsurfer41099,

This line is incomplete …

final_word = [1:len(new_word)]

The slice specifier [1:len(new_word)] needs to follow the string that is to be sliced, namely new_word.

Also, to satisfy the requirements of the exercise, you need to assign the solution to new_word.


So I just changed final_word to new_word, passed but I get this

File “python”, line 9
new_word = [1:len(new_word)]
SyntaxError: invalid syntax

With ^ pointing to the :


this square brackets:


tell python you want to take a slice, but of what? Python has no idea. You need to specify the variable you want a slice of before the square brackets, so python now you want a slice of, in this case, new_word

it is and it never was about final_word


I now understand. From the tutorial all I’m seeing is that there’s just a letter ‘s’ for the variable that contains ‘charlie’ but never recognized it as such. I think it would need to be changed to first_name to show it as such.


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