My First Python Script

Ed Hotchkiss edhotchkiss at gmail.com
Fri Sep 16 05:33:21 CEST 2005


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050915/01cca413/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: IP.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20050915/01cca413/attachment.ksh>


More information about the Python-list mailing list