do/while structure needed

Ten runlevelten at gmail.com
Sun May 14 10:38:03 EDT 2006


On Sunday 14 May 2006 06:17, 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.

while not comparison(original_set, trans_letters):
    random.shuffle(letters)
    trans_letters = ''.join(letters)[:len(original_set)]

trans_table = string.maketrans(original_set, trans_letters)

HTH,

Ten

-- 
There are 10 types of people in this world,
those who understand binary, and those who don't.



More information about the Python-list mailing list