Welcome folks today in this blog post we will be completely removing all
whitespaces such as spaces, and tab characters from text file in python. All the full source code of the application is shown below.
In order to get started you need to make an
app.py file and copy paste the following code
f = open("file.txt")
output = ""
for line in f:
line = line.rstrip()
o = open("output.txt","w")
Here we are taking the
input text file and removing all the whitespaces from it and saving it to a new
text file as shown below
Now if you execute the below python script by typing the below command as shown below