# Slash2Dash.py """ Solicits a slash-date and prints the equivalent dash-date. """ x = raw_input('Enter a valid slash-date: ') n = len(x) # Location of the first '/' # Compute n1 so that x[n1]=='/' is True. # The first slashis either in position 1 or 2 if x[1]=='/': n1 = 1 else: n1 = 2 # Location of the second '/'. # Compute n2 so that x[n2]=='/' is True. # The second slash is either in position n-3 or n-5 if x[n-3]=='/': n2 = n-3 else: n2 = n-5 # The day slice... day = x[:n1] if len(day)==1: # Add a '0' if the day is a single digit day = '0' + day else: day = x[:n1] # The month slice... if n2==n1+3: # Add a '0' if the month is a single digit month = x[n1+1:n2] else: month = '0' + x[n1+1:n2] # The year slice... year = x[n2+1:] if len(year)==2 and int(year)<=16: # This 2-digit year is from the 1900's year = '20' + year if len(year)==2 and int(year)>16: # This 2-digit year is from the 2000s year = '19' + year prettyDate = day + '-' + month + '-' + year print prettyDate