Python 3 Script to Remove Leading and Trailing Spaces From String Using Strip() Method Full Project For Beginners

Python 3 Script to Remove Leading and Trailing Spaces From String Using Strip() Method Full Project For Beginners

 

Welcome folks today in this blog post we will be removing trailing and leading spaces from string using strip() method in  python. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

app.py

 

s = "           sdfsdfdsf sdfsdfsf     "

print(s.strip())

 

 

Here we are using the strip method which is a built in method in python. Now if you execute the python script by typing the below command as shown below

See also  Python 3 Script to Check PC or Laptop OS Last Reboot Time Using psutil Library Full Project For Beginners

 

python app.py

 

 

Leave a Reply