Python: Abbreviate 'Road' as 'Rd.' in a given string
Python Regular Expression: Exercise-30 with Solution
Write a Python program to abbreviate 'Road' as 'Rd.' in a given string.
import re street = '21 Ramkrishna Road' print(re.sub('Road$', 'Rd.', street))
21 Ramkrishna Rd.
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?