Given a list like this:
mylist = [\"name\", \"state\", \"name\", \"city\", \"name\", \"zip\", \"zip\"]
I would like to rename the duplicate
You can use hashtable to solve this problem. Define a dictionary d. key is the string and value is (first_time_index_in_the_list, times_of_appearance). Everytime when you see a word, just check the dictionary, and if the value is 2, use first_time_index_in_the_list to append '1' to the first element, and append times_of_appearance to current element. If greater than 2, just append times_of_appearance to current element.