Please Help Me with My Code Checking


#1

I am having continued issues with my code. I keep getting the error message in the exercise below. Please help, because I have been look at it for hours and can't see the issue. I wrote as the exercise instructed if i'm not mistaken.

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


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


#2

This is because you not only need to equal new_word to your slice but your slice and something else. So for example:

new_word = something[1:len(new_word)]

#3

I still keep getting an error, so should i make something a variable with a random value?
Traceback (most recent call last):
File "python", line 7, in
NameError: name 'something' is not defined


#4

Ok well when I meant something I mean something has to go in that place for it to work xD. It is not a random value actually it is a value you use often in this. Think about it for a minute. You only have new_word equal to the slice but you need something and the slice.


#5

If you need me to give you a bigger hint just let me know. I am trying to help you find it out on your own without just giving you the answer but we all have "writer's block" type moments from time to time so I understand if you want something closer to the actual answer


#6

Yeah I need a bigger hint, as i have looked at this for quite some time and not seen the issue or how to fix it.


#7

If you have a "slice" like this: [1:5]

Then what are you slicing? It's like saying the 5th index. 5th index of what?

How is it done in the instructions?
How is it done when you google for examples on slicing in python?


#8

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