day1/exercise/datestring.py
author Santosh G. Vattam <vattam.santosh@gmail.com>
Tue, 02 Mar 2010 10:55:49 +0530
changeset 374 0ba81871dae5
parent 354 5dc6c3673f9d
child 386 a0bec380b44f
permissions -rw-r--r--
Branches merged.

month2mm = { 'JAN': 1, 'FEB': 2, 'MAR': 3, 'APR': 4, 'MAY': 5,
'JUN': 6, 'JUL': 7, 'AUG': 8, 'SEP': 9, 'OCT': 10, 'NOV': 11,
'DEC': 12 }

COMMA = ','
SPACE = ' '
date_str = raw_input('Enter a date string? ')
date_str = date_str.replace( COMMA, SPACE)
d, m, y = date_str.split()
dd = int( d )
mon = m[:3].upper()
mm = month2mm[mon]
yyyy = int( y )

print dd,mm, yyyy