[Tutor] overlapping tuples

Alan Gauld alan.gauld at yahoo.co.uk
Fri Feb 28 05:13:01 EST 2020


On 28/02/2020 04:03, Narasimharao Nelluri wrote:

>     if fir[1] >= sec[0] and fir[1] <=sec[1]:=======>Here i am validating
> 2nd element in first variablae is in-between seconds variable if it is
> there is a overlap

In python you can write that more concisely as:

    if sec[0] <= fir[1] <= sec[1]:

>     if sec[0] >= fir[0] and sec[1] <= fir[1]:=====> Here i am checking if
> first element in second variable is in-between second variable , there is a
> oberlap


In that case shouldn't the index to sec be the same in both comparisons?
The comparison style above would have eliminated that error...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list