Python program to find non repeating characters in a string

Find nonrepeating characters in a string

The string is a combination of characters when 2 or more characters join together it forms string whether the formation gives a meaningful or meaningless output. In python programming, we treat a single character also as a string because there is noo datatype as a character in python. In this python program, we will find unique elements or nonrepeating elements of the string.

Python program to find nonrepeating characters in a string


  • Step 1:- Start.
  • Step 2:- Take user input.
  • Step 3:- Start iterating through string.
  • Step 4:- Initialize count variable.
  • Step 5:- Again start iterating through same string.
  • Step 6:- Increment count variable as character is found in string.
  • Step 7:- If count is more then 2 break the loop.
  • Step 8:- If count is 1 print the character.
  • Step 9:- End.

Python program to find nonrepeating characters in a string

#take user input
String = input('Enter the string :')
for i in String:
    #initialize a count variable
    count = 0
    for j in String:
        #check for repeated characters
        if i == j:
        #if character is found more than 1 time
        #brerak the loop
        if count > 1:
    #print for nonrepeating characters
    if count == 1:
        print(i,end = " ")
Enter the string :ChampakChacha
m p k c

One comment on “Python program to find non repeating characters in a string”


    // Here is my java program
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Scanner;
    import java.util.Set;
    public class Program14 {

    static void foundUnique(String s1) {
    Map map = new HashMap();
    for (int i = 0; i < s1.length(); i++) {
    if (map.containsKey(s1.charAt(i)))
    map.put(s1.charAt(i), map.get(s1.charAt(i)) + 1);
    map.put(s1.charAt(i), 1);
    Set keys = map.keySet();
    for (Character ch : keys) {
    if (map.get(ch) == 1)
    System.out.print(ch + ” “);

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner sc = new Scanner(;
    System.out.print(“Enter the String : “);
    String s1 = sc.nextLine();