Python 3 Script to Remove Leading Zeros (0’s) From IP Address Full Project For Beginners

Python 3 Script to Remove Leading Zeros (0’s) From IP Address Full Project For Beginners

 

Welcome folks today in this blog post we will be removing leading zeros (0's) from ip address in python.All the full source code of the application is given below.

 

 

Get Started

 

 

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

See also  Python 3 Tkinter Dropdown Formatted Calendar Widget with Date and Time GUI Script Desktop App Full Project For Beginners

 

app.py

 

def remove_zeros_from_ip(ip_add):
      new_ip_add = ".".join([str(int(i)) for i in ip_add.split(".")])  
      return new_ip_add ;

print(remove_zeros_from_ip("255.024.01.01"))
print(remove_zeros_from_ip("127.0.0.01 "))

 

 

Now if you execute the python script by typing the below command as shown below

 

python app.py

 

 

Leave a Reply