Find strings in a list that between specific ascii values – Python

I am trying to find certain string in a list that are between a lowerbound and upperbound (these are user input values). For example say I have a list, states = [‘OH’, ‘NJ’, ‘NY’, ‘SD’, ‘NH’, ‘WI’]. The user inputs lowerbound = ‘NJ’ and upperbound = ‘SD’. I want the code to output [‘OH’, ‘NJ’, ‘NY’, ‘SD’].

Remove element from a list based on condition in pandas dataframe

a= {‘A’ : [1, 2,3,4], ‘B’ : [‘FOOTBALL’,’BASKETBALL’,’HANDBALL’,’VOLLEYBALL’], ‘C’ : [[5,10,15,40],[1,4],[20,10,40],[10,40]] } How can I remove the element 40 from C if B is different to FOOTBALL Like this : A B C 0 1 FOOTBALL [5, 10, 15, 40] 1 2 BASKETBALL [1, 4] 2 3 HANDBALL [20, 10] 3 4 VOLLEYBALL [10] Answers: … Read more