No indexError in string slicing

Hello Jupyter community users,
Iam in very beginning stage of jupyter notebook course. :slightly_smiling_face: :slightly_smiling_face:

My query is " why don’t we get same error in cell3 as we get in cell1" ?
Because in cell3 i have exceeded the string length and calling index values from 4-19 which is empty.
Similarly I have called 20index value in cell1 which is empty but I get error as out of range
:face_with_head_bandage: anyone please explain.
i know it’s a basic thing but finding a lot to answer myself

Regards
Nish

You state you are in the beginning of a ‘jupyter notebook course’. You probably are learning Python using Jupyter notebook as the environment/interface. Jupyter notebook supports many languages, such as Julia, Bash, and R, through kernels.

So when seeking help, you need to keep in mind is your issue tied to Jupyter or is it tied to the language I am running in the kernel. If it is tied to the language you are using, then you want to seek help in places targeted at that language. Not here, which is targeted at the Jupyter world. Python is able to be run aside from the Jupyter notebook and sometimes you can tell if it is a Python issue if you run that code in those places and see the same result. If your course isn’t showing you how to run Python elsewhee, you may want to ask or look into it yourself.

That being said, a lot of people knowledgeable in Python are here…
Here your issue has to do indexing and slicing in Python. Look into those. (Hint: try a lower number in cell #1.)

1 Like

Apologizes for asking silly ques.
Thank you for your reply @fomightez :slightly_smiling_face: :slightly_smiling_face: :slightly_smiling_face:

Maybe this is a python query which i asked.
I got your point name[3] will give ans.

But I was looking for “why no such errors In cell3” even though it is out of range.

Yes, sorry. I saw error in cell #1. Still my point holds about looking into how indexing and slicing in Python are different.

1 Like