random / lists
M. Clift
noone at here.com
Sun Aug 15 19:31:15 EDT 2004
Hi Wes,
Thanks for responding.
What I want is a system that controls the direction in a generated list. If
the user selects a number a letter is choosen for each number from at random
from an array. That's fine and easy to do. The hard part is, is that no
letter can be repeated with only one letter interveining and the letters can
only follow each other under certain rules.
These being :
1. 'a' can be followed by any letter
2. 'b' can only be followed by 'c'
3. 'c' can be followed by 'a' or 'd'
4 'd' can be followed by 'a' or 'c'
Really it doesn't matter what these rules are for the time being it's just
working out a way to control the outcome of a list of unknown size. I've
experimented with lists of say up to 10 long using ' if ' statements for
each number and different array depending upon the previous letter, but as
you can imagine it is no good for larger lists as the code just goes on and
on : ). Rather than I have done before, whereby I said if letter 3 == 'a'
then letter 4 = choice(bcd) is it possible to say if previous letter equals
whatever then this letter equals whatever?
Wes, if you recieved an email direct to you address I'm sorry. I must
be tierd, as for some reaon I've been hitting the reply button all night
instead of the reply to group!
Thanks
More information about the Python-list
mailing list