Checking whether two rectangles overlap in python using two bottom left corners and top right corners
<pre><code>class Point:

    def __init__(self, xcoord=0, ycoord=0):
        self.x = xcoord
        self.y = ycoord

class Rectangle:
    def __init__(self, bottom_left, top_right, colour):
        self.bottom_left = bottom_left
        self.top_right = top_right
        self.colour = colour

    def intersects(self, other):
</code></pre>

<p>I am trying to see if two rectangles intersect based on the upper right and lower left corners however when I make the function:</p>

<pre><code>def intersects(self, other):
    return self.top_right.x&gt;=other.top_right.x&gt;=self.bottom_left.x and self.top_right.x&gt;=other.bottom_left.x&gt;=self.bottom_left.x and self.top_right.y&gt;=other.top_right.y&gt;=self.bottom_left.y and self.top_right.x&gt;=other.bottom_left.x&gt;=self.bottom_left.x
</code></pre>

<p>The function will return false when inputting:</p>

<pre><code>r1=Rectangle(Point(1,1), Point(2,2), 'blue')
r3=Rectangle(Point(1.5,0), Point(1.7,3), 'red')
r1.intersects(r3)
</code></pre>

<p>into the shell.</p>