create a list of tuples from two lists

Question:

I have two lists:

list1=[1,2,3,4]
list2=[5,6,7]

I want to convert it to a list of tuples. The final output should be like this

list_tuple = [(1,5), (1,6), (1,7), (2,5), (2,6), (2,7), (3,5), (3,6), (3,7), (4,5), (4,6), (4,7)]
Asked By: GhizlaneHazam

||

Answers:

import itertools
list(itertools.product(list1, list2))

Let me know if you are looking for doing it without any imports.

Answered By: Anant Mittal