+ 1

Can someone explain me what are slices? And what is there output??by giving any example please tell me

Please tell me

26th May 2021, 3:46 PM
LION CODER
LION CODER - avatar
3 ответов
+ 3
I think you mean list slicing in python. List slicing is used to access a range of elements in a list. To access the element you need to slice a list. For example, Lst is a list with considering with the below output: Lst = [50, 70, 30, 20, 90, 10, 50] Now if you want another list containing output: [70, 30, 20]. How will you do that? Here comes a list slicing. To do this you have to like this: Lst2=Lst[1:4] Here the first value is the starting point of the index(here 1 means start from index 1) and the last value is the ending point(note:4 means the last index of the list will be 4-1=3) There is also a third parameter which is for index jump. For example : print(Lst[2:5:2]) #output [30,90] This will help you to know briefly about list slicing: https://www.geeksforgeeks.org/python-list-slicing/
26th May 2021, 4:30 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
The future is now thanks to science thanks you got me Now I understand it Thanks for your time and you explained it very nicely😁❤
26th May 2021, 4:36 PM
LION CODER
LION CODER - avatar
+ 1
Jan markus oh no I am not talking about bread slice I was referring to list slice in python sry I didn't said that!😅
26th May 2021, 4:35 PM
LION CODER
LION CODER - avatar