+ 1

What is slicing of data in lists ?

6th Oct 2025, 3:10 PM
Akash Pokhrel
Akash Pokhrel - avatar
3 Respuestas
+ 4
Slicing, as it suggests, a slice of something. In other word, a portion of something. Real world example, a slice of a pizza. Python list: my_list = [1, 2, 3, 4, 5] If you want to get [2, 3] from it, you "slice" it with my_list[1:3]. print(my_list[1:3]) gives you [2, 3], "a slice of the list."
6th Oct 2025, 3:36 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 3
Akash Pokhrel , > slicing is explained in the `python developer` tutorial in the module `working with lists`. may be you can re-read this module. > slicing can look a bit confusing, especially when *negative slicing* or a mix of *negative and positive* slicing is used. > it is recommended to practice this repeatedly because slicing can be very helpful. it can be applied to lists, strings, tuples,... and is also available in some other programming languages.
6th Oct 2025, 3:41 PM
Lothar
Lothar - avatar