Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get list values in b/w indexes python

result = []
sublist = []

separators = ('COMMENT', 'BORDER')
mylist = ['ABC', 'COMMENT', 'YES', 'YES', 'NO', '123', 'COMMENT','GONOW','MAKE','COMMENT', 'YES','COMMENT', 'BORDER', 'FOO', '123']

for x in mylist:
    if x in separators:
        if sublist:
            result.append(sublist)
        sublist = []
    else:
        sublist.append(x)
result.append(sublist)

print (result)
Comment

PREVIOUS NEXT
Code Example
Python :: big python code 
Python :: Preprocessing of transfer learning inception v3 
Python :: how to select the three highest entries within a category in pandas 
Python :: create layer file arcpy 
Python :: print two values using f string 
Python :: dimension reduction using pca 
Python :: regular expression for allowing specific numbers of characters python 
Python :: Normalize basic list data 
Python :: scatter plot python color according to gender 
Python :: run python script from applescript 
Python :: function for getting the basic statistic of our Dataframe in one go 
Python :: The most appropriate graph for your data 
Python :: pythonanywhere API example 
Python :: fix the error when you close turtle screen in your own main loop 
Python :: ERROR: Target path exists but is not a directory, will not continue. 
Python :: Move x-ticks to the middle of each bin 
Python :: python code optimization 
Python :: unpack list 
Python :: python nc group variables 
Python :: pd.read_csv how to cumsum a column 
Python :: if user_answer==answer: ecpeted index erroe pythin fx 
Python :: how to stop gambling 
Python :: python console ending multiline input 
Python :: weight constraints keras cnn 
Python :: quando è stata inventata la lavastoviglie 
Python :: concatenate dataframes using one column 
Python :: Return the intersection of this RDD and another one 
Python :: Gets an existing SparkSession or, if there is no existing one, creates a new 
Python :: jwt authentication python flask 
Python :: python compactar arquivo antes de exportar 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =