Help: new_word=[1:len(new_word)] didn't work


#1

when I code as below,

new_word=[1 : len(new_word)]

it returns an error: SyntaxError: invalid syntax…
does I code wrong? please help…
thanks!


#2

and the Syntax Error is at the colons…


#3

the general syntax for string slicing is:

"string"[start:stop]

you don’t have the string before the square opening bracket, so python is unaware of what it should take a slice, so it throws an error


#4

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