[Tutor] How do I go about this?
dyoo at hkn.eecs.berkeley.edu
Wed Jul 27 23:13:11 CEST 2005
On Wed, 27 Jul 2005, Nathan Pinno wrote:
> How do I go about the following: I want to write a program that will
> print two lists one after another, then show all the available
> possibilities for matches e.g a0 and x0.
> lista = [x0, x1, x2, x3]
> listb = [a0, a1, a2, a3]
It sounds like you're asking for the mathematical idea of "crossing" both
Here's a slightly simpler problem that might be easier for you to solve:
Let's say you have an element 'x0' in hand, as well as 'listb'. Can you
produce all the matches between x0 and each element in listb? Let's call
this function match().
(If you have a better name for this, use that name instead. *grin*).
We'd expect match() to behave something like this:
match('x0', ['a0', 'a1', 'a2', 'a3'])
==> [('x0', 'a0'),
Can you write 'match()'? If so, you should be very close in writing
something that crosses both lists together.
More information about the Tutor