{"id":20312,"date":"2021-09-09T19:57:58","date_gmt":"2021-09-09T14:27:58","guid":{"rendered":"https:\/\/python-programs.com\/?p=20312"},"modified":"2021-11-22T18:36:22","modified_gmt":"2021-11-22T13:06:22","slug":"python-program-to-find-all-non-repeated-characters-in-a-string","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-all-non-repeated-characters-in-a-string\/","title":{"rendered":"Python Program to Find All Non Repeated Characters in a String"},"content":{"rendered":"

In the previous article, we have discussed Program to Find Lexicographic Rank of a Given String<\/a><\/p>\n

Given a string and the task is to find all the Non repeated characters in a given String.<\/p>\n

Counter function in Python:<\/strong><\/p>\n

The counter is a set and dict subset. Counter() takes an iterable entity as an argument and stores the elements as keys and the frequency of the elements as a value. So, in collections, if we transfer a string. When you call Counter(), you\u2019ll get a Counter class object with characters as keys and their frequency in a string as values.<\/p>\n

Counter() returns a Counter type object (a subclass of dict) with all characters in the string as keys and their occurrence count as values. We\u2019ll use the [] operator to get the occurrence count of the characters from it.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given String = \"hello this is btechgeeks\"<\/pre>\n

Output:<\/strong><\/p>\n

In a Given String,{ hello this is btechgeeks } all Non-repeating Characters are:\r\no b c g k<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given String = \"good morning btechgeeks\"<\/pre>\n

Output:<\/strong><\/p>\n

In a Given String,{ good morning btechgeeks } all Non-repeating Characters are:\r\nd m r i b t c h k s<\/pre>\n

Program to Find All Non-Repeated Characters in a String in Python<\/h2>\n

Below are the ways to find all the Non repeated characters in a given String:<\/p>\n