If the step is always +1 (which is the default for range) the following should be more efficient than converting each list to a set or iterating over either list:
range(max(x[0], y[0]), min(x[-1], y[-1])+1)
More Related Contents:
- Deleting certain elements in a list [closed]
- Search list for number in range
- Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
- Identify groups of continuous numbers in a list
- What is the difference between range and xrange functions in Python 2.X?
- Why does range(start, end) not include end?
- Should you always favor xrange() over range()?
- range() for floats
- Is it possible to implement a Python for range loop without an iterator variable?
- Python, Matplotlib, subplot: How to set the axis range?
- Python 3 turn range to a list
- How do I use a decimal step value for range()?
- `xrange(2**100)` -> OverflowError: long int too large to convert to int
- NameError: global name ‘xrange’ is not defined in Python 3
- converting a list of integers into range in python
- How to check if the current time is in range in python?
- Concatenating two range function results
- Unbounded range()
- Only index needed: enumerate or (x)range?
- How to set the subplot axis range
- Union of multiple ranges
- range over character in python
- Is there a need for range(len(a))?
- Python 3 range Vs Python 2 range
- Is it possible to make a `for` loop without an iterator variable? (How can I make make code loop a set number of times?)
- Skip over a value in the range function in python
- Does range() really create lists?
- Python: Checking to which bin a value belongs
- Limiting user input to a range in Python
- Strange result when removing item from a list while iterating over it in Python