Python Forum

Full Version: Working with lists homework (2)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Define 2 lists. The first one must contain the integer values 1, 2 and 3 and the second one the string values a, b and c. Iterate through both lists to create another list that contains all the combinations of the A and B elements. The final list should look like one of the 2 lists:



[1a, 1b, 1c, 2a, 2b, 2c, 3a, 3b, 3c]
[a1, a2. a3, b1, b2, b3, c1, c2, c3]


Make the final list contain all possible combinations : [1a, a1, 1b, b1, 1c, c1, 2a, a2, 2b, b2, 2c, c2, 3a, a3, 3b, b3, 3c, c3]

Thank you!
What have you tried?
Where do you need help?
As well as make a more descriptive title next time
Hello, So I just learned how to create lists:

intlist = []
strlist = []

intlist.append(1)
intlist.append(2)
intlist.append(3)

strlist.append('a')
strlist.append('b')
strlist.append('c')
And from here I am stuck. The teacher didn't tell us how to iterate through both lists to create another list that contains all the combinations of the A and B elements.

no need for help I did it
Quote:no need for help I did it
Did you solve the homework problem or did you change title and tags? Can't really figure that out from your last post
I think it is not solved. He asked the same question in the mailing list.
Changing the title thread does not change the thread ID. Which is how it knows its the same thread that everyone is subscribed to, etc.

Please also report your solution so future coders with the same question can figure it out
(Feb-28-2018, 09:56 AM)metulburr Wrote: [ -> ]Please also report your solution so future coders with the same question can figure it out
Currently there is one more thread regarding this same exercise by another member. I think it's too early to share the solution