1st nonrepeating character in a string || String Manipulation || Python

In this we are going to see a basic example of 1st nonrepeating character in a string in Python Programming Language.

def firstNonRepeatingCharacter(str1):
  character_order = []
  count = {}
  for ch in str1:
    if ch in count:
      count[ch] += 1
    else:
      count[ch] = 1 
      character_order.append(ch)
  for ch in character_order:
    if count[ch] == 1:
      return ch
  return None

str1 = "abcabcedydej"
x = firstNonRepeatingCharacter(str1)
print(x)

# Coded By Dhiraj Shelke

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post