+ 6
Write a program to print the common characters of a string.
16 Answers
+ 6
eg-...if i entered "aparna"...then output should be....aaa
+ 4
i mean common characters
+ 4
more thxn once Ben Allen (Njinx)
+ 4
than*
+ 4
tell me in c or c++ HonFu
+ 4
yes
+ 4
thanks Ben Allen (Njinx)
+ 3
do you mean characters that appear more than once?
+ 3
So you want to count how often a letter occurs in a string?
In Python you could do something like:
string='Whatever'
for x in set(string.lower()):
print('Letter {}: {} times'.format(
x, string.count(x)))
Or if you really just want to print the repeated letters:
for x in set(string.lower()):
print(x*string.lower().count(x))
+ 2
Do you want it to output ones that appear more than once, or only the most common characters?
+ 2
I'll try and make something in C++
+ 2
Sorry, Crystal - can't. ;-)
+ 1
What do you mean by the same characters? Can't you just print the string. A string is just an array of characters
+ 1
Can you be more specific? What do you mean by common characters?
+ 1
do you mean the one that repeats more than one times??