Oct-27-2022, 08:59 PM
Is this the kind of thing you're looking for?
date_list = ['D4', '7', '2004\n'] # a data sample for index, item in enumerate(date_list): if index == 0: month = item.lstrip("D") month = "D" + str(f"{int(month):02d}") elif index == 1: day = str(f"{int(item):02d}") else: year = item.rstrip("\n") date = f"{month}/{day}/{year}" print(date)
Output:D04/07/2004
Sig:
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
>>> import this
The UNIX philosophy: "Do one thing, and do it well."
"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse
"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein