Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- date = input("Enter the date in DD/MM/YYYY format: ")
- date = date.split("/")
- # Check if the date was correct
- if len(date) != 3:
- print("The entered date is incorrect")
- else:
- # Create variables for day, month and year
- day = int(date[0])
- month = int(date[1])
- year = int(date[2])
- if len(str(year)) != 4:
- print("The year is invalid")
- else:
- # Check if the day is between 1 and 31, and month between 1 and 12
- if 1 < day < 31 and 1 < month < 12:
- # Change month to a string with month's name
- if month == 1:
- month = "Jan"
- elif month == 2:
- month = "Feb"
- elif month == 3:
- month = "Mar"
- elif month == 4:
- month = "Apr"
- elif month == 5:
- month = "May"
- elif month == 6:
- month = "Jun"
- elif month == 7:
- month = "Jul"
- elif month == 8:
- month = "Aug"
- elif month == 9:
- month = "Sep"
- elif month == 10:
- month = "Oct"
- elif month == 11:
- month = "Nov"
- elif month == 12:
- month = "Dec"
- # Display date in "MMM DD, YYYY" format
- fullDate = month + " " + str(day) + ", " + str(year)
- print("The date is " + fullDate)
- else:
- # If the day or month values are incorrect
- print("The date is invalid")
- print("The day is " + str(day) + " and the month is " + str(month))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement