I need to take 5 inputted dates in the format "january 1" and order them chronologically.
one = input('birthday 1: ')
two = input('birthday 2: ')
three = input('birthday 3: ')
four = input('birthday 4: ')
five = input('birthday 5: ')
months=['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']
ord_months=[]
birthday1 = one.split() # converts "january 1" into a list of ['january', '1']
birthday2 = two.split()
birthday3 = three.split()
birthday4 = four.split()
birthday5 = five.split()
for i in range(12): # range of 12 for 12 months
if birthday1[0] == months[i]: # calls index 0 of months, in the example above it would be january
ord_months.append(i) # adds the value of i to the ord_months list
for i in range(12):
if birthday2[0] == months[i]:
ord_months.append(i)
for i in range(12):
if birthday3[0] == months[i]:
ord_months.append(i)
for i in range(12):
if birthday4[0] == months[i]:
ord_months.append(i)
for i in range(12):
if birthday5[0] == months[i]:
ord_months.append(i)
ord_months.sort()
print("month:", ord_months[0]+1, 'day:', birthday1[1])
print("month:", ord_months[1]+1, 'day:', birthday2[1])
print("month:", ord_months[2]+1, 'day:', birthday3[1])
print("month:", ord_months[3]+1, 'day:', birthday4[1])
print("month:", ord_months[4]+1, 'day:', bir
I made a list of the months then i converted them into numbers then sorted the numbers. This orders the months but not the days, which i am confused about how to do.