I want to replace a searched text in an array from a specified element to another specified element in this array. I know there is a “replace” function but it will replace all the occurrences of that searched field. So I want to know if there is another function or another trick that can do what I want Like this:
myarray = ["time (1)",
"the text to replace ",
"time (2)",
"the text to replace ",
"time (3)",
"the text to replace ",
"time (4)",
"the text to replace ",
"time (5)",
"the text to replace ",
"time (6)",
"the text to replace ",
"time (7)",
"the text to replace ",
"time (8)",
"the text to replace ",
"time (9)",
"the text to replace ",
"time (10)",
"the text to replace "]
myfunc(4,8)
def myfunc(fromtime, totime):
for line in myarray
#find the time from (fromtime) to (totime) and replace 'text' with 'string' for example
print myarray
Can any one help me? Please! Thank you!
list, not anarray) actually the word "time", or are they actual timestamps?