Python: Replace whitespaces with an underscore and vice versa
Python Regular Expression: Exercise-23 with Solution
Write a Python program to replace whitespaces with an underscore and vice versa.
import re text = 'Python Exercises' text =text.replace (" ", "_") print(text) text =text.replace ("_", " ") print(text)
Python_Exercises Python Exercises
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?