How do I split a list in an alphabetical range? I need to filter out a list with ranges "a" through "m" and ranges "n" through "z"

I have a main list which contains key value pairs that I would like to split into two separate lists. First half ranges A-M and second half ranges N-Z.

example of data trying to split:

Main_list = ['a 1', 'her 1', 'her 1', 'lately','mr 1', 'ornament 1', 
             'pleased 1', 'saturday 1', 'view 1', 'youth 1']

Result of data split:

list1 = ['a 1', 'her 1', 'her 1', 'lately','mr 1']

list2 = ['ornament 1', 'pleased 1', 'saturday 1', 'view 1', 'youth 1']

Read more here:

Content Attribution

This content was originally published by Marceloo at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: