How to select a chunk of list between two values in python
问题 I have a list of values like this: vect_i = ['a','X','c','g','X','t','o','X','q','w','e','r','t','y','u','i','o','p','Y','x','c','v','b','Y','b','n','m','Y','q','a','d','Y',] my goal would be to select in a smart way only the values that are within the last X and the first Y (notice capital X and Y). The output should be something like this: vect_f = ['q','w','e','r','t','y','u','i','o','p','Y','x','c','v','b'] Is there a smart way to do this selection. I have figured out a way to do it by