Slicing a list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Slicing a list

Say I have Red = [1,2,3,4,5] How do I slice backward and foward leaving out 3? So that: Backward: Red_1 = [1,2] Foward: Red_2 = [4,5]

5th Oct 2021, 7:36 PM
Richard
Richard - avatar
3 Answers
0
Jay Matthews is there are way (a) can be = 2 because I am writing binaru search algorithm
5th Oct 2021, 7:48 PM
Richard
Richard - avatar
0
Not the most efficient way but thanks
5th Oct 2021, 7:58 PM
Richard
Richard - avatar
0
Your binary search is very efficient. but I did it like this: https://code.sololearn.com/clyjkVX33NK8/?ref=app
6th Oct 2021, 4:53 AM
Richard
Richard - avatar