w3resource logo


Python Exercises

Python: Remove leading zeros from an IP address

Python Regular Expression: Exercise-16 with Solution

Write a Python program to remove leading zeros from an IP address.

Sample Solution :-

Python Code :

import re
ip = "216.08.094.196"
string = re.sub('\.[0]*', '.', ip)
print(string)

Python Code Editor:

import re
ip = "216.08.094.196"
string = re.sub('\.[0]*', '.', ip)
print(string)

Improve this sample solution and post your code through Disqus



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program