Hi,
let’s say I have the following lists:
firstList = [1,2,3,4,5]
secondList = [6,7,8,9,0]
If I pass the first list into the following function as an argument, it will ‘work’; no exception is raised.
def myzip(*seqs):
seqs = [list(S) for S in seqs] # <---- test this outside as standalone
res = []
while all(seqs):
res.append(tuple(S.pop(0) for S in seqs))
return res
result_one = myzip(firstList) # No exception is raised
However, if I attempt the following:
result_one = [list(S) for S in firstList] # Exception raised: TypeError: 'int' object is not iterable
If I try two lists as an argument, then no exception is raised.
combinedList = firstList, secondList
result_two = [list(S) for S in combinedList]
Can someone reconcile this please. That is, the list comprehension works if implied via a function
argument but does not work when explicit when only one list is passed in.