0

I want the list to be in this order ['PRE','IMP','POST','BO']

Where the actual list will have duplicates of each e.g.

Desired List

list = ['PRE', 'PRE', 'PRE','IMP', 'IMP','POST','BO', 'BO']

A possible out of order list:

list = ['IMP', 'PRE', 'PRE','IMP', 'IMP','POST','BO', 'BO']

I want to simply write code to check that the entire list follows the sequence order.

if list is in order:
    print("correct")
else:
    print("incorrect")
JLuka
  • 25
  • 5
  • 1
    Your edit suggests that you didn't read the duplicate, or understand how to apply it. Basically, `sorted(values, key=lambda x: {"PRE": 0, "IMP": 1, "POST": 2, "BO": 3}[x])` – tripleee Sep 26 '22 at 15:07
  • The latter is the case, thank you! – JLuka Sep 26 '22 at 15:10

0 Answers0