python-algorithm
leetcode 1507. Reformat Date
무적김두칠
2022. 4. 8. 11:47
1
2
3
4
5
6
|
class Solution:
def reformatDate(self, date: str) -> str:
month=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
date=date.split()
ans=date[2]+'-'+'%.2d'%(month.index(date[1])+1)+'-'+'%.2d'%(int(date[0][:-2]))
return(ans)
|
cs |
반응형