How to find double letter in string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to find double letter in string?

3rd Aug 2020, 8:26 AM
AARTI SHELAR
AARTI SHELAR - avatar
6 Answers
+ 5
AARTI SHELAR , are you looking for a dedicated character to find, or you need to get all duplicated characters presented in a list or dict together with their number of occurrence? Should the duplicates be consecutive or does position not matter?
3rd Aug 2020, 9:58 AM
Lothar
Lothar - avatar
+ 4
please show us your attempt.
3rd Aug 2020, 8:42 AM
Rohit
+ 4
A way of doing this with python modules would be using groupby(): from itertools import groupby test = 'abbcccxxa' print([''.join(g) for _, g in groupby(test)]) # result: ['a', 'bb', 'ccc', 'xx', 'a']
3rd Aug 2020, 4:09 PM
Lothar
Lothar - avatar
+ 2
Duplicate consecutive
3rd Aug 2020, 10:13 AM
AARTI SHELAR
AARTI SHELAR - avatar
0
S="google" L=list(re.findall('\w\1',S))
3rd Aug 2020, 9:28 AM
AARTI SHELAR
AARTI SHELAR - avatar
0
It is not give deserve output!
3rd Aug 2020, 9:29 AM
AARTI SHELAR
AARTI SHELAR - avatar