def dedup(l, suffix='__'):
 new_l = []
 seen = {}
 for s in l:
  if (s in seen):
   seen[s] += 1
   s += (suffix + str(seen[s]))
  else:
   seen[s] = 0
  new_l.append(s)
 return new_l

def dedup ( l , suffix = '__' ) : new_l = [ ] seen = { } for s in l : if ( s in seen ) : seen [ s ] += 1 s += ( suffix + str ( seen [ s ] ) ) else : seen [ s ] = 0 new_l . append ( s ) return new_l
de-duplicates a list of string by suffixing a counter always returns the same number of entries as provided .