Given an IP address as input, write a Python program to remove leading zeros from it.
Examples:
Input: 216.08.094.196
Output: 216.8.94.196
Input: 216.08.004.096
Output: 216.8.4.96
In this program, we are using sub() method of "re" module.
Syntax:
re.sub(pattern, repl, string, count=0, flags=0)
The sub() in the function stands for SubString, a certain regular expression pattern is searched in the given string(3rd parameter), and upon finding the substring pattern is replaced by repl(2nd parameter), count checks and maintains the number of times this occurs.
Code
Output
need an explanation for this answer? contact us directly to get an explanation for this answer