May-02-2018, 03:48 PM
(This post was last modified: May-02-2018, 03:49 PM by ThiefOfTime.)
I would suggest to use the zip function in combination with a for loop if you want to compare the first elements, then the second elements, etc.
so instead of you two for loops use:
so instead of you two for loops use:
list_1 = [12.4, 2.7, 5.1] list_2 = [10.9, 2.3, 3.7] for element_1, element_2 in zip(list_1, list_2): if element_1>=5 and element_2>=5: a.extend((element_1,element_2)) elif element_1<5 and element_2>=5: b.extend((element_1,element_2)) elif element_1>=5 and element_2<5: c.extend((element_1,element_2)) elif element_1<5 and element_2<5: d.extend((element_1,element_2)) print(a, b, c, d)