But then I still get the error with the len(x) statement .. hmm On 9/15/05, James Stroud <jstroud at mbi.ucla.edu> wrote: > > Try the % operator with strings. > > For instance: "%03.d" % 5 > > py> "%03.d" % 5 > '005' > > This operator, from what I have experienced, has the same properties as > the > unix printf. In python, I think its called "string formatting". > > James > > On Thursday 15 September 2005 20:33, Ed Hotchkiss wrote: > > 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. > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com/ > -- > http://mail.python.org/mailman/listinfo/python-list > -- edward hotchkiss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20050915/6361e193/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4