In: Computer Science
Write a Python program to take as input 5 birthdays from 5 users (1 each) and output them in chronological order. Dates should include the month and day (not year) in the format “June 6” as a single input per user.
If you any doubts, please give me comment...
months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
birthdays = []
print("Enter 5 input birthdays(Format: Month and day, Ex: June 6): ")
for i in range(5):
birthday = input()
birthdays.append(birthday)
for i in range(5):
for j in range(5):
temp1 = birthdays[i].split()
temp2 = birthdays[j].split()
month1 = months.index(temp1[0])
month2 = months.index(temp2[0])
if month1<month2 or (month1==month2 and int(temp1[1])<int(temp2[1])):
birthdays[i], birthdays[j] = birthdays[j], birthdays[i]
print("\nEntered birthdates in chronological order is")
for date in birthdays:
print(date)
