[Tutor] All possible 16 character alphanumeric strings?

akleider at sonic.net akleider at sonic.net
Sun Sep 16 05:13:32 CEST 2012

> possible = "234567abcdefghijklmnopqrstuvwxyz"
> word_length = 16
> print 'Running "every.py"'
> word_list = []
> def add_word(word):
>     if len(word)==word_length:
>         word_list.append(word)
>         print word
>     else:
>         for c in possible:
>             new_word = word + c
>             add_word(new_word)
> The only problem with this code is that it actually takes a word as its
> input and just checks that it is == word length. If not it just appends
> the
> string possible to the variable word that was called in the function
> add_word.
> I need to be able to generate every possible combination of the characters
> in the variable possible, ideally coming up with a string that resembles
> the TOR hidden network strings that look like this:
> "kpvz7ki2v5agwt35.onion"
> Scott

Actually it doesn't even do that. It only prints "running 'every.py'"!
You forgot the line that does all the work:
I'm attaching the whole file so you don't miss the important bit.
Run it and see what happens, but be ready to CNTL-C (I'm assuming you are
running Linux, I think it'll be the same on Mac, all bets are off
regarding M$ Windoz:-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: every.py
Type: text/x-python
Size: 435 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20120915/55f1b0b0/attachment.py>

More information about the Tutor mailing list