0

Slicing is extremely confusing

I recently learned indexing and to me that was a breeze but slicing confuses me deeply. I thought you could just apply the indexing rules to slicing. Can someone help me understand this better please?

26th Feb 2024, 12:29 PM
Nicole Krason
6 Réponses
+ 2
[start:stop:step size] start is inclusive stop is exclusive all are integers.
26th Feb 2024, 12:55 PM
Lisa
Lisa - avatar
+ 2
I hope these small tutorials will help you a little bit more: https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_strings_slicing.asp https://www.freecodecamp.org/news/slicing-and-indexing-in-python/ the start character is inclusive, the end character is exclusive (in python too, but not in all languages)
26th Feb 2024, 12:58 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
Tag the relevant programming language
26th Feb 2024, 12:49 PM
Lisa
Lisa - avatar
0
Lisa updated
26th Feb 2024, 12:53 PM
Nicole Krason
0
I wish the lesson said, for example, [0:3] will only include 0 through 2, but not 3. When explained that way, it makes total sense to me. I had to go to YouTube to understand slicing. Lisa i haven't learned step size, so I have no idea what that is
26th Feb 2024, 1:00 PM
Nicole Krason
0
Mihaly Nyilas thank you!
26th Feb 2024, 1:00 PM
Nicole Krason