The function can be implemented using a for loop. Given an input string s. Iterate over each character in the string using enumerate objects in the loop, i.e. enumerate(s). The enumerate() function adds a counter to an iterable and returns it in the form of an enumeration object, i.e. each character c is accompanied by a position index. Use this position index to count the occurrences of a character up to its position index, i.e. s[:index+1].count(c). Returns the first character whose counter is greater than 1.