Blog Archive

search

Wednesday, August 7, 2019

Python program to find the first non-repeating character in given string

a = input('Enter a string : ')
char_order = []
ctr = {}
for c in a:
    if c in ctr:
      ctr[c] += 1
    else:
      ctr[c] = 1
      char_order.append(c)
for c in char_order:
    if ctr[c] == 1:
        print(c)
        break

No comments:

Post a Comment

Python program to create a string from two given strings concatenating uncommon characters of the said strings

PROGRAM :  a = input('Enter a string : ') b = input('Enter a string : ') c='' for i in a:     if(i not in b):...