John Salerno wrote:

> 1 random.shuffle(letters)
> 2 trans_letters = ''.join(letters)[:len(original_set)]
> 3 trans_table = string.maketrans(original_set, trans_letters)
>
> So what I'd like to do is have lines 1 and 2 run once, then I want to do
> some comparison between original_set and trans_letters before running
> line 3. If the comparison passes, line 3 runs; otherwise, lines 1 and 2
> run again.
>
> A do/while would be good for this, but perhaps I'm looking at it in the
> wrong way? Or is there some kind of do/while type of idiom that I could use?
>
> Thanks.

I guess you want something like:

while True:
    random.shuffle(letters)
    trans_letters = ''.join(letters)[:len(original_set)]
    if some_compatison(original_set,trans_letters):
        trans_table = string.maketrans(original_set, trans_letters)
        break


HTH,
George

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to