+ 1

How to find double letter in string?

3rd Aug 2020, 8:26 AM
AARTI SHELAR
AARTI SHELAR - avatar
7 Antworten
+ 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
minirkk
minirkk - avatar
+ 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