"Ending up" 10/11


Python keeps giving me the following error code:

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

The 'roof' icon (Don't know what it is called in English) is located underneath the colon, as if it is referring to the colon not belonging there.
I have no clue what I'm doing wrong, any help is welcome!
Thanks in advance! :slight_smile:

pyg = 'ay'

original = raw_input('Enter a word:')

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

    print new_word
    print 'empty'


try using the same code but add spaces and different syntax and contact me if it doesn't: work :slight_smile::grinning::smile_cat:


I have no clue what other syntax I would have to use.
Also where do you mean the spaces have to be added? Throughout the whole code or the '[1:len(new_word)]' part?
I did try it in the '[1:len(new_word)]' part but it still gave me the same error about the Syntax.


look at this code:

"hello world"[0:6]

see how i put the string (this can also be variable containing string) before the square brackets so python knows i want a slice of "hello world"


This made everything as clear as water! Thank you very much! :smile:


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