Loop in a loop?
sturlamolden at yahoo.no
Thu Jan 17 18:21:16 CET 2008
On 17 Jan, 14:38, Sacred Heart <scrd... at gmail.com> wrote:
> Okey, so if my array1 is has 4 elements, and array2 has 6, it won't
> loop trough the last 2 in array2? How do I make it do that?
In that case your problem is the data. You'll either have to truncate
one array and/or pad the other.
Or is this what you want?
n = len(array1) if len(array1) < len(array2) else len(array2)
for number,letter in zip(array1[:n],array2[:n]):
print "%s %s" % (number,letter)
reminder = array1[n:] if len(array1) > len(array2) else array2[n:]
for x in reminder: print x
More information about the Python-list