Ending Up HELP


#1



Replace this line with your code.


Can someone please explain why it is not
new_word = [1:len(new_word)]
I really do not understand??????????????
I know len() is suppose to count the characters. The 1 is suppose to count the letter that is assigned one. Yes I know we start counting from 0. Whats up with the brackets????? I promise I want to break my computer and just give up.


#2

The above syntax indicates an index slice, but it does not have an object to index.

object = object_to_slice[ ... ]

Your code is similar to many topics posted recently which would indicate copying and pasting, and not writing according to the instructions. There is nothing to be learned by doing this.

On the chance that you are just having difficulty determining the order of the code, then move all the code in lines 2 through 5 inclusive to inside the if statement where print original is now.

1. pyg = 
2. user input
3. validate input
4. code
5. else
6. empty

#3

Thank you for your explanation.
new_word = new_word [1:len(new_word)]
so new_word after the = sign is indicating what is going to be sliced?
1:len if it were [1:3(new_word)]

then I would just get new

Please let me know I would hate to continue code academy learning something incorrectly.
Thank you in advance.


#4

Given a string, "new_word", the first three letters would be a slice that looks like this...

'new_word'[:3]  =>  'new'

Our program is attempting to remove the first letter only...

"new_word"[1:len('new_word')]  =>  'ew_word'

#5

Now i makes more sense.
Thank you


#7

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