Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. List1 = ["a", "b"]
  2. List2 = ["c", "d"]
  3.  
  4. # if you want the concatenate the two strings
  5. List3 = [i+j for i in List1 for j in List2]
  6.  
  7. # if you want to make tuples out of the objects
  8. List4 = [(i, j) for i in List1 for j in List2]
  9.  
  10. # the itertools module has functions for a lot of combinatorics operations
  11. import itertools
  12. List5 = list(itertools.product(List1, List2))
  13.  
  14. print(List3)
  15. print(List4)
  16. print(List5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement