[Tutor] How to run this block of code dozens of times
Dave Angel
d at davea.name
Mon Sep 17 02:23:43 CEST 2012
On 09/16/2012 07:56 PM, Scurvy Scott wrote:
> scratch that, new code is below for your perusal:
>
> from Crypto.PublicKey import RSA
> import hashlib
>
> def repeat_a_lot():
> count = 0
> while count < 20:
You're kidding, aren't you? while loops are meant for those times when
you don't know how many times the loop is to iterate.
> m = RSA.generate(1024)
> b = hashlib.sha1()
> b.update(str(m))
> a = b.hexdigest()
> print a[:16] + '.onion'
> count += 1
> repeat_a_lot()
>
>
>
def repeat_a_lot():
for _ in xrange(20):
m = RSA.generate(1024)
b = hashlib.sha1()
b.update(str(m))
a = b.hexdigest()
print a[:16] + '.onion'
repeat_a_lot()
--
DaveA
More information about the Tutor
mailing list