<div> </div>
<div>Sweet, time to play with python for a whole day today :P<br><br> </div>
<div><span class="gmail_quote">On 9/16/05, <b class="gmail_sendername">Gary Wilson Jr</b> <<a href="mailto:gdub@ece.utexas.edu">gdub@ece.utexas.edu</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Ed Hotchkiss wrote:<br>> def ZeroThrough255():<br>> x = 0<br>> while x <= 255:<br>
> if len(x) == 1:<br>> mySet = '00' + str(x)<br>> elif len(x) == 2:<br>> mySet = '0' + str(x)<br>> else:<br>> mySet = x
<br>> print mySet<br>> x +=1<br>><br>> ZeroThrough255()<br><br>Instead of using the while loop and a counter, you can use the range()<br>function. Using range() and string formatting you could to something like:
<br><br>def ZeroThrough255():<br> for num in range(256):<br> print "%03d" % num<br><br>which, using a list comprehension and the string join() function, could also<br>be written as:<br><br>def ZeroThrough255():
<br> print "\n".join(["%03d" % num for num in range(256)])<br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote>
</div><br><br clear="all"><br>-- <br>edward hotchkiss