Ending up new_word = new_word[1:len(new_word)] vs new_word = new_word[1:]]


#1

Hi guys, I have a question in regards to Ending up.
what is the difference between using new_word = new_word[1:len(new_word)]
as opposed to new_word = new_word[1;] ?

 new_word = new_word[1:len(new_word)]

vs

new_word = new_word[1;]

Both gave me the same results ultimately(minus the fact it wasn’t what Codecademy wanted) so I am wondering out of curiosity why one over the other? Why do I need the len() function? Is new_word[0] wrong or just differnt?

thanks for any input


#2

Hi @jamesandtara,

This should work, provided that the code that you have preceding it is correct …

new_word = new_word[1:len(new_word)]

This will not work because you have a semicolon where there should be a colon …

new_word = new_word[1;]

If you replace the semicolon with a colon, it would be equivalent to the first example, and should work if the code that precedes it in your submission is correct.


#3

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