I have a list of items from which I need to separate items with specific "key". Let's say I need all items that follow "X" -> the list may look like this: `Y1 1-2 X1 3-5 Z1 6-8, Y2 3-5 X2 5-7 Z2 5-9` so I need to take the X "values" that are `3-5` and `5-7`. These should be returned this way: `3 4 5` and `5 6 7` and on their own lines so that they can be used in another functions.

I have also tried taking "X"s to its own dictionary but the problem is still the same. I also know about end="" but it does not help me with this.

```
def get_x_values(list_parameter):  

list_of_items = []
list_of_x = []

for i in list_parameter:
    i = i.split(' ')
    for item in i:
        if item != '':
            list_of_items.append(item)
for item, next_item in zip(list_of_items, list_of_items[1:]):
    if item == 'X':
        list_of_x.append(next_item)
for x in list_of_x:
    for i in range(int(x[0]), int(x[-1]) + 1):
       yield i

```

When I loop the yield values trough, I get the X values like this:

```
3
4
5
5
6
7 

```

When I need them this way:

```
3 4 5
5 6 7

```

Any help appreciated.