How to calculate the product of a list with itself in Python

1 Answer

0 votes
from itertools import *     
 
def view_calc(lst):         
    for i, item in enumerate(lst, 1):             
        print(item, end=' ')             
        if (i % 4) == 0:                 
            print()         
    print()
    

view_calc(list(product(range(4), repeat=2)))
 
 
'''
run:
 
(0, 0) (0, 1) (0, 2) (0, 3) 
(1, 0) (1, 1) (1, 2) (1, 3) 
(2, 0) (2, 1) (2, 2) (2, 3) 
(3, 0) (3, 1) (3, 2) (3, 3) 
 
'''

 



answered May 25, 2019 by avibootz
...