<filename>Aniyom Ebenezer/Phase 2/STRINGS/Day_34_Challenge_Solution/Question 1 Solution.py<gh_stars>1-10
"""
Write a Python program to find the first non-repeating character in given string.
"""

def first_non_repeatimg_character(str1):
    char_order = []
    ctr = {}
    for c in str1:
        if c in ctr:
            ctr[c] += 1
        else:
            ctr[c] = 1
            char_order.append(c)
    for c in char_order:
        if ctr[c] == 1:
            return c
    return None
print(first_non_repeatimg_character("abcd"))
print(first_non_repeatimg_character("abcdabcdef"))
print(first_non_repeatimg_character("aaabbcc"))
<filename>Aniyom Ebenezer/Phase 2/STRINGS/Day_34_Challenge_Solution/Question 1 Solution.py<gh_stars>1-10
"""
Write a Python program to find the first non-repeating character in given string.
"""

def first_non_repeatimg_character(str1):
    char_order = []
    ctr = {}
    for c in str1:
        if c in ctr:
            ctr[c] += 1
        else:
            ctr[c] = 1
            char_order.append(c)
    for c in char_order:
        if ctr[c] == 1:
            return c
    return None
print(first_non_repeatimg_character("abcd"))
print(first_non_repeatimg_character("abcdabcdef"))
print(first_non_repeatimg_character("aaabbcc"))
Write a Python program to find the first non-repeating character in given string.