Create a function that accepts 3 inputs, a string, a starting location, and a length.  The function needs to simulate the string endlessly repeating in both directions and return a substring beginning at the starting location and continues for length.

Example:
```python
endless_string('xyz', -23, 6) == 'yzxyzx'
```
To visualize:

           Negative                               Positive
    3         2         1         *         1         2         3      
    0987654321098765432109876543210123456789012345678901234567890
    xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzx
           ******
         -23 for a length of 6 == 'yzxyzx'
       
Some more examples:
```python
endless_string('xyz', 0, 4) == 'xyzx'
endless_string('xyz', 19, 2) == 'yz'
endless_string('xyz', -4, -4) == 'zxyz'
```

A negative length needs to include the starting postion and return the characters to the left of the starting position.

Difficulty: introductory

Starter code:

def endless_string(string, start, length):
	

Solutions:
from itertools import cycle, islice

def endless_string(string, start, length):
    i = (start + (length + 1 if length < 0 else 0)) % len(string)
    return ''.join(islice(cycle(string), i, i + abs(length)))

from itertools import cycle, islice

def endless_string(stg, i, l):
    i = min(i, i+l) % len(stg) + (l < 0)
    j = i + abs(l)
    return "".join(islice(cycle(stg), i, j))

from itertools import cycle, islice

def endless_string(string, start, length):
    r = (start + (length + 1)*(length < 0)) % len(string)
    return ''.join(islice(cycle(string), r, r+abs(length)))

def endless_string(s, start, l):
    s = s * 500
    half = len(s) // 2
    return s[half + start:(half + start) + l] if l > 0 else  s[half+start+l+1:half+start+1]

def endless_string(strng, start, length):
    len_strng = len(strng)
    strng = strng * (abs(length) // len_strng + 1)
    true_start = min(start, start + length)
    start = true_start % len_strng + (length < 0)
    stop = start + abs(length)
    return strng[start:stop]



#from itertools import cycle, islice

#def endless_string(strng, start, length):
#    true_start = min(start, start + length)
#    start = true_start % len(strng) + (length < 0)
#    stop = start + abs(length)
#    return "".join(islice(cycle(strng), start, stop))


def endless_string(stg, i, l):
    ls = len(stg)
    stg = stg * (2 + abs(l) // ls)
    i = min(i, i + l) % ls + (l < 0)
    j = i + abs(l)
    return stg[i:j]