How to pad leading zero (in a function) dynamically?
<p>I know that <code>"%03d"</code> can do that pretty easily, but I'm trying to solve a slightly different problem. The part of my script, I need to find out how many numbers in a range (e.g. 0-999) have at lest one 3 (or any digit in question) in it. So, I came up with this lambda function:</p>

<pre><code>fx = lambda z,y=999: [ "%03d" % (x, ) for x in range(y) if str(z) in str(x) ]
</code></pre>

<p>which is working great but I want to automate the padding 'leading zero' bit according to the range e.g. 003 when it's 999 or 09 for 88 and so on. Any idea how can I do that?</p>
