how can sort my code in time sequence(12 1 2 3 ... 10 11)? I got random input and sort it into am/pm. Here's my code:
time = input("Please enter the boost times: ")
lst = time.split()
def lenght(t):
if len(lst[i]) == 7:
h = lst[i][5]
return h
elif len(lst[i]) == 6:
h = lst[i][4]
return h
lsta = []
lstp = []
def ampm(t):
if ord(lenght(lst[i])) == ord('a'):
if str(lst[i][1]) == str("2"):
lsta.insert(0,lst[i])
else:
lsta.append(lst[i])
elif ord(lenght(lst[i])) == ord('p'):
if str(lst[i][1]) == str("2"):
lstp.insert(0,lst[i])
else:
lstp.append(lst[i])
i = 0
while i < len(last):
lenght(lst[i])
ampm(lst[i])
i += 1
and here's my example result from this code by now;
Please enter the boost times: 11:00am 12:59am 5:02pm 7:02am 8:00pm
['12:59am', '11:00am', '7:02am'] ['5:02pm', '8:00pm']