a = [1, 2, 4, 5, 7, 8, 10] n = len(a) d = 3 c = [] for i in range(n): for j in range(i,n): for k in range(j,n): for x,y,z in zip(a[i],a[j],a[k]): print(x,y,z)
Error : Traceback (most recent call last):
File “”, line 8, in TypeError: ‘int’ object is not iterable
It works when I convert list object to string but not working in int.
Advertisement
Answer
Because indexing will give back the object and not an iterable container here. unless you call it like this: zip([a[i]], [a[j]], [a[k]])
.
a = [1, 2, 4, 5, 7, 8, 10] n = len(a) d = 3 c = [] for i in range(n): for j in range(i,n): for k in range(j,n): for x,y,z in zip([a[i]], [a[j]], [a[k]]): print(x,y,z)