hi everyone!
I am a beginner and I can't find answer for this:
one = [" January ", " February ", " March ", " April ", " May ",
" June ", " July ", " August ", " September ", " October ",
" November ", " December ", " ", "IPS", "COL", "BRT"]
two = ["/01/", "/02/", "/03/", "/04/", "/05/", "/06/", "/07/", "/08/",
"/09/", "/10/", "/11/", "/12/", ",", "", "", ""]
a = len(one)
b = len(two)
while a>0:
text = open("database.txt", "r")
text = ''.join([i for i in text]).replace(one[a], two[a])
x = open("new_database.txt","w")
x.writelines(text)
x.close()
a = a - 1
the error is:
text = ''.join([i for i in text]).replace(one[a], two[a])
IndexError: list index out of range
if anyone can help, much appreciated!
question from:
https://stackoverflow.com/questions/65893597/replace-index-use-as-variable-for-a-loop 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…