[Tutor] Checking the format of IP address...
Guillermo Fernandez Castellanos
guillermo.fernandez.castellanos at gmail.com
Fri Nov 3 12:18:58 CET 2006
I would probably take the string, separate the numbers and check they
# Check if my IP address has 4 numbers separated by dots
if not len(num)==4:
# Check each of the 4 numbers is between 0 and 255
for n in num:
if int(n) < 0 or int(n) > 255:
You could also go the regexp way, but I find it a bit more complicated.
Hope it helps,
On 11/3/06, Asrarahmed Kadri <ajkadri at googlemail.com> wrote:
> Hi Folks,
> I want to implement a simple program that verifies the IP provided by the
> user is in the right format or not.
> How to go about it..?
> Any suggestions..
> To HIM you shall return.
> Tutor maillist - Tutor at python.org
More information about the Tutor