/ pset3 / outdated / outdated.py
outdated.py
 1  months = [
 2      "January",
 3      "February",
 4      "March",
 5      "April",
 6      "May",
 7      "June",
 8      "July",
 9      "August",
10      "September",
11      "October",
12      "November",
13      "December",
14  ]
15  while True:
16      date = input("Date: ").strip()
17      if "/" in date:
18          x, y, z = date.split("/")
19          if x.isdigit() == False:
20              continue
21          else:
22              x = int(x)
23          if x > 12:
24              continue
25          y = int(y)
26          if y > 31:
27              continue
28          z = int(z)
29          print(f"{z}-{x:02d}-{y:02d}")
30          break
31      else:
32          x, y, z = date.split(" ")
33          if "," in y:
34              y = y.replace(",", "")
35          else:
36              continue
37          if y.isdigit() == False:
38              continue
39          else:
40              y = int(y)
41          if y > 31:
42              continue
43          z = int(z)
44          a = 1
45          for n in months:
46              if x == n:
47                  x = a
48                  break
49              else:
50                  a = a + 1
51                  continue
52          x = int(x)
53          print(f"{z}-{x:02d}-{y:02d}")
54          break