How to get a subset of a list by python
This article is about how python gets a subset of the list. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Get a subset of the list
Sometimes, you only need some of the elements in the list. Here are some ways to get a subset of the list.
X = [1 print x [: 3] > # the first 3 print x [: 3] > [1 Magazine 2] # four print x in the middle [1:5] > [2 pencils 3] # the last 3 print x [3:] > [4 pencils 5] # Odd item print x [: 2] > [1pas x [1JZ 2] > [2pas 4pas 6] Thank you for reading! This is the end of the article on "how to get a subset of the python list". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!