On 8/26/05, <b class="gmail_sendername">Alberto Troiano</b> &lt;<a href="mailto:albertito_g@hotmail.com">albertito_g@hotmail.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi everyone<br><br>I need to generate a password..It has to be an 8 digit number and it has to<br>be random<br><br>The code I've been trying is the following:<br><br><br>import random<br>random.randrange(00000000,99999999)
<br><br>The code works but sometimes it picks a number with 7 digits. Is there any<br>way that I can tell him to select always a random number with 8 digits?<br><br>Thanks in advanced<br><br>Alberto<br></blockquote></div>
<br>
Along with everyone else's solutions, I'll throw out:<br>
<br>
&nbsp; str(random.randrange(99999999)).zfill(8)<br>
<br>
&nbsp; -Arcege<br>-- <br>There's so many different worlds,<br>So many different suns.<br>And we have just one world,<br>But we live in different ones.