Python: Remove lowercase substrings from a given string
Write a Python program to remove lowercase substrings from a given string.
Sample Solution:
Python Code:
import re
str1 = 'KDeoALOklOOHserfLoAJSIskdsf'
print("Original string:")
print(str1)
print("After removing lowercase letters, above string becomes:")
remove_lower = lambda text: re.sub('[a-z]', '', text)
result = remove_lower(str1)
print(result)
Sample Output:
Original string: KDeoALOklOOHserfLoAJSIskdsf After removing lowercase letters, above string becomes: KDALOOOHLAJSI
Flowchart:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to insert spaces between words starting with capital letters.
Next: Write a Python program to concatenate the consecutive numbers in a given string.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics