So I have a  script, first part of a script that I am making to determine each possible combination of IP addresses that are out there.
 
This part is just to get the end of the IP (the last 3 digits). So, they are from 0 - 255. I just want to print 0 - 255, HOWEVER
 
If the number is only say ... 3, then I want mySet to be 003, not 3. I need to add the zeros to the front.
My code is below - I guess that there is something to do with my variable types etc. I am not used to the way that Python handles variable types so I am kind of lost, can anyone help ...
 

# Script to Evaluate every possible IP Address Combo

# 9/15/05

def ZeroThrough255():

x = 0

while x <= 255:

if len(x) == 1:

mySet = '00' + str(x)

elif len(x) == 2:

mySet = '0' + str(x)

else:

mySet = x

print mySet

x +=1

ZeroThrough255()

--------------------

The file is also attached.

--
edward hotchkiss
# Script to Evaluate every possible IP Address Combo
# 9/15/05

def ZeroThrough255():
        x = 0
        while x <= 255:
                if len(x) == 1:
                        mySet = '00' + str(x)
                elif len(x) == 2:
                        mySet = '0' + str(x)
                else:
                        mySet = x
                print mySet
                x +=1   

ZeroThrough255()

 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to