Read text file into a variable and replace all newlines with space using python programming
belongs to collection: Exercises for Intermediate python developers
All Answers
total answers (1)
belongs to collection: Exercises for Intermediate python developers
total answers (1)
Hint:
replace()function to replace all newlines (\n) with space (' ').Solution:
- First, open the file in a read mode
- Next, read all content from a file using the read() function and assign it to a variable.
- Next, use string
- Display final string
need an explanation for this answer? contact us directly to get an explanation for this answerreplace()function to replace all newlines (\n) with space (' ').