L
L
liaset2020-05-27 18:23:15
Python
liaset, 2020-05-27 18:23:15

Is it possible to replace several identical letters in a row with one?

Imagine that I have a variable name = "Sereegga Paaankov", how can I make sure that these identical letters in a row are replaced by one? That is, to name = "Serge Pankov".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2020-05-27
@0xD34F

re.sub(r'(.)\1+', r'\1', name)

A
Anton Muravyov, 2020-05-27
@Murean

Not satisfied with the usual cycle?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question