Using itertools.groupby
:
>>> foo = "SSYYNNOOPPSSIISS"
>>> import itertools
>>> ''.join(ch for ch, _ in itertools.groupby(foo))
'SYNOPSIS'
More Related Contents:
- Split Strings into words with multiple word boundary delimiters
- Filter pandas DataFrame by substring criteria
- Pythonic way to create a long multi-line string
- How to get the value of a variable given its name in a string? [duplicate]
- About the changing id of an immutable string
- Converting a string representation of a list into an actual list object [duplicate]
- How to delete a character from a string using Python
- Remove all special characters, punctuation and spaces from string
- Check if a word is in a string in Python
- Pandas Extract Number from String
- Python str vs unicode types
- Standard way to embed version into Python package?
- python: SyntaxError: EOL while scanning string literal
- n-grams in python, four, five, six grams?
- How do I remove leading whitespace in Python?
- Finding a substring within a list in Python [duplicate]
- Best way to parse a URL query string
- Python string literal concatenation
- Why is variable1 += variable2 much faster than variable1 = variable1 + variable2?
- Convert a string to integer with decimal in Python
- What is a clean way to convert a string percent to a float?
- Determine precision and scale of particular number in Python
- When to use %r instead of %s in Python? [duplicate]
- Python: Find a substring in a string and returning the index of the substring
- Best way to loop over a python string backwards
- Extracting words from a string, removing punctuation and returning a list with separated words
- How to use str.contains() with multiple expressions in pandas dataframes
- How to merge two json string in Python?
- How does str(list) work?
- How to remove all integer values from a list in python