In this program, we will take a string as input and create a string that consists of multi-time occurring characters in the said string.
Steps to solve the problem
- Take a string as input.
- From collections import counter to count the occurrences of the characters in the given string.
- Print only those characters who have occurred more than once.
#Input string
str1 = "aabbcceffgh"
#Importing counter
from collections import Counter
str_char = Counter(str1)
part1 = [ key for (key,count) in str_char.items() if count>1]
#printing output
print("Occurring more than once: ", "".join(part1))
Output :
Occurring more than once: abcf