[Tutor] Question on list

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Sep 12 12:52:13 EDT 2003



On Fri, 12 Sep 2003, james roy wrote:

> I am new to programming with python. I dont know whether i should ask
> this question here or not.

Hi James,

Welcome aboard!  Yes, you're in the right place; Tutor is exactly meant
for questions like this.



> I am having my problem like this:
>
> I am having a few lists that i know in no dynamically.
> For example:
>
> List1 = ['1','2','3']
> List2 = ['/']
> List3 = ['4','5','6']
>
> I want to make the combinations like this:
>
> '1' '/' '4'
> '1' '/' '5'
> '1' '/' '6'
> '2' '/' '4'
> '2' '/' '5'
> '2' '/' '6'
> '3' '/' '4'
> '3' '/' '5'
> '3' '/' '6'


If a problem is too complicated, one approach we can take to solve it is
to change the problem.  *grin* Actually, I'm being slightly serious: if we
make the problem simpler and solve the simpler problem, we might learn
enough to do the real thing.


Here's a simplification of the problem: if you're just given an element of
List1, and the whole of List3,

###
element = 1
List3 = ['4', '5', 6']
###

Can you generate the three combinations?

    '1' '/' '4'
    '1' '/' '5'
    '1' '/' '6'



Good luck to you!




More information about the Tutor mailing list