def check_for_triangle(tri, lines):
    lines_needed = zip(tri, (tri[1], tri[2], tri[0]))
return all(line in lines or line[::-1] in lines for line in lines_needed)
lines = [('B', 'C'), ('D', 'A'), ('D', 'C'), ('A', 'B'), ('D', 'B')]
tri1 = 'B', 'C', 'D'
tri2 = 'A', 'B', 'E'
print(check_for_triangle(tri1, lines))
print(check_for_triangle(tri2, lines))
Checking that the geometry for a triangle is contained in a list of lines