Linked Questions

Popular Questions

Iterating 2 lists different lengths

Asked by At

im iterating list1 in reverse to find the first element that is lower than the highest possible number in list2 but im running into problems when list1 is significantly shorter than list2 even though list2 has a value < i.

    lst1 = [2, 4]
    lst2 = [3, 5, 7, 8, 9, 10, 12, 13]

    val = None
    for i in lst1[::-1]:
        if i < lst2[-1]:
            val = i
    index = val

Related Questions