Ending Up


#1

Here is my code:

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)]

else:
print 'empty'

The error message is this:
File "python", line 9
new_word= [1:len(new_word)]
^
SyntaxError: invalid syntax

I dont know what im doing wrong because i entered what the instructions said to do and did not change anything else so i dont think an error should be popping up. what am i doing wrong?


#2

you need to specify what you want to slice off, example:

s = "hello world"
print s[0:5]

see how i specify the variable (in this case s) before the square brackets? This way, you tell of what variable/string you want a slice, you need to do the same for your slice, and then store the slice in new_word


#3

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