human
Append digits to the end of duplicate strings to make all strings in an array unique | Function to replace duplicate strings by alphanumeric strings to make all strings in the array unique.
Store the frequency of strings.
Iterate over the array.
For the first occurrence , update the frequency count.
Otherwise.
Append frequency count to end of the string.
Print the modified array.
Driver Code.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to append digits to the end of duplicate strings to make all strings in an array unique and the other steps required.
 def replaceDuplicates ( names ) :
	hash = { }
	for i in range ( 0 , len ( names ) ) :
		if names [ i ] not in hash :
			hash [ names [ i ] ] = 1
		else :
			count = hash [ names [ i ] ]
			hash [ names [ i ] ] += 1
			names [ i ] += str ( count )
	for i in range ( 0 , len ( names ) ) :
		print ( names [ i ] , end = ' ▁ ' )
if __name__ == ' _ _ main _ _ ' :
	str1 = [ " aa " , " bb " , " cc " , " bb " , " aa " , " aa " , " aa " ]
	replaceDuplicates ( str1 )