Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

first unique character in a string in python

def firstUniqChar(s):
    data = {}
    for i in range(len(s)):
        if s[i] not in data:
            data[s[i]] = i
        else:
            data[s[i]] = -1

    for i in data.values():
        if i >= 0:
            return i
    return -1
Source by eolnuha.com #
 
PREVIOUS NEXT
Tagged: #unique #character #string #python
ADD COMMENT
Topic
Name
3+3 =