Inactive Tutor answered 04/03/21
# You get ONE LESS than the ending index
inputDateStr = "1985-08-01"
strSliceMonth = inputDateStr[5:7]
strSliceYear = inputDateStr[0:4]
outbuffDate = strSliceMonth + "-" + strSliceYear
print(outbuffDate)
Bart H.
asked 04/03/21I want to make this date which is this 1985-08-01 what would be the numbers to make it look like this 08-1985 and the best I have done at slicing is doing this [ : 7] but that only gives me the date 1985-08 which isn't what I need.
Inactive Tutor answered 04/03/21
# You get ONE LESS than the ending index
inputDateStr = "1985-08-01"
strSliceMonth = inputDateStr[5:7]
strSliceYear = inputDateStr[0:4]
outbuffDate = strSliceMonth + "-" + strSliceYear
print(outbuffDate)
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.