It has been a while, and I am having trouble wrapping around the algorithm I'm trying to do. Basically, I have two lists and you want to get all combinations of these two lists.
Maybe I wonโt explain it correctly, so here is an example.
name = 'a', 'b' number = 1, 2
the output in this case will be:
1. A1 B2 2. B1 A2
The hard part: I can have more elements in the variable "name" than in the variable "number" (the number will always be equal to or less than the variable name).
I got confused how to make all combinations (nested in a loop?) And even more confused with logic to move elements in a name variable in case there are more elements in the list than in the list of numbers.
I am not the best programmer, but I think I can give him a chance if someone can help me clarify the logic / algorithm to achieve this. So I was just stuck on nested loops.
Update:
Here is the output with three variables and two numbers:
name = 'a', 'b', 'c' number = 1, 2
exit:
1. A1 B2 2. B1 A2 3. A1 C2 4. C1 A2 5. B1 C2 6. C1 B2
python list algorithm combinations
user1735075 Oct 17 2018-12-17T00: 00Z
source share