Blockquote
I have a date string in the format Day Month Year, like 1st Mar 1984, 4th Apr 1973, 22nd May 2006, where:
Day is in the set {"1st","2nd","3rd",...,'"30th","31st"}
Month is in the set {"Jan","Feb","Mar",...,"Dec"}
Year is in the range [1900,2100]
I gotta convert the date string to the format YYYY-MM-DD, like: 1st Mar 1984 -> 1984-03-01 4th Apr 1973 -> 1973-04-04
(The function reformatDate has the following parameters: dates[dates[0],...,dates[n-1]] is an array of date strings in the format Day Month Year)
Sample Input 4 20th Oct 2052 6th Jun 1933 26th May 1960 20th Sep 1958
Sample Output 2052-10-20 1933-06-06 1960-05-26 1958-09-20
enter code here
def reformatDate(dates):
# write your code here
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
dates_count = int(input().strip())
dates = []
for _ in range(dates_count):
dates.item = input()
dates.append(dates_item)
result = reformatDate(dates)
fptr.write('\n'.join(result))
fptr.write('\n')
fptr.close