# [Tutor] overlapping tuples

Alan Gauld alan.gauld at yahoo.co.uk
Sat Feb 29 08:05:26 EST 2020

```On 29/02/2020 01:36, Narasimharao Nelluri wrote:
> Thanks Mats for your inputs.  overlap means if two numbers share across two
> tuples For Ex  if we take two tuples (1,20) and (15,20)  there is a
> over lap because 15,6,17,18,19,20  numbers are sharing between these
> two sets.

When programming you need to be precise. tuples, sets and ranges are 3
very different things. You are treating tuples as ranges. In your
problem the tuple (1,5) represents the range 1,2,3,4,5.
But to us(and Python) a tuple is a collection of items. The tuple (1,5)
means just the two numbers 1 and 5. Its OK to use tuples to store the
range limits like that but we can't guess, you need to explain that to us.

And likewise sets has a specific meaning - a collection of unique
items (for some arbitrary definition of uniqueness).

ranges are also a thing in Python, you can define a range from
n to m-1 as range(n,m-1). That returns a range object. You might
find it easier to solve your problem if you use range objects

--
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

```