Improve your Python skills with Exercise 17: Slicing | HolyPython.com
Python Slicing Exercises
Let’s check out some exercises that will help you understand and master how Python’s Slice Notions, Slicing and Advanced Slicing works.
Exercise 17-a
Slice the word until first "a". (Tosc)
[start:stop] notation can be used to slice a Python string.
Just keep in mind that in [start:stop] notation, stop value won’t be included. So, you need to type the index of the last value you’d like to include +1.
ans_1 = wrd[0:4]
or
ans_1 = wrd[:4]
or
ans_1 = wrd[:4:1]
Exercise 17-b
Slice the word so that you get "cana".
[start:stop] notation can be used to slice a Python string.
Just keep in mind that in [start:stop] notation, stop value won’t be included. So, you need to type the index of the last value you’d like to include +1.
ans_1 = wrd[3:]
or
ans_1 = wrd[3::1]
Need More Exercises?
Check out Holy Python AI+ for amazing Python learning tools.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.

Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython