The : error


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:new_word]
print original
print 'empty'

That is my code and whenever I run it it gives me this error. On line 9 : is invalid syntax. Can anyone help me?


to take a slice of a string, we need to specify of which string we want a slice, we do this by placing the string before the square brackets:

x = "hello world"
print x[0:6]

in your case, you shouldn't print, you should store the slice. But this code was just for demonstration

also, list slicing requires integer values, new_word is not a integer


Thanks @stemim94 it really helped I fixed my code!!