So, I am using a text file to store the last time data was pulled from an api, after I check if new data should be pulled I am updating the last datapoint with this code:
if pullAgain == True:
lasttimedata = open('lasttimemultiple.txt', 'a+') # open last time again
for item in splitData:
if item[0:2] == PullType:
newTime = PullType + ':' + currenttime #formats the data point
lasttimedata.write(newTime) #trying to write that data point to the spot of the old point.
print('We updated the last time')
lasttimedata.close() # close last time
There is two ways for doing what you ask:
Keep a counter to know witch element to edit:
for index, item in enumerate(splitData): splitData[item] = new_value
But your are editing the list while iterating, and that is not always a great idea.
Create an output list will the element you want:
output_list =  for item in splitData: if i_want_to_keep: output_list.append(item) else: output_list.append(new_value)