How to get all combinations from two lists in Python

1 Answer

0 votes
from itertools import product
 
lst1 = ["python", "java", "c++"]

lst2 = [1, 2, 3, 4]

for lst in list(product(lst1, lst2)):
    print(lst)
   

    
        
'''
run:
        
('python', 1)
('python', 2)
('python', 3)
('python', 4)
('java', 1)
('java', 2)
('java', 3)
('java', 4)
('c++', 1)
('c++', 2)
('c++', 3)
('c++', 4)

'''

 



answered Oct 2, 2021 by avibootz
...