I have a list like this 

```
list_ = [" ", " ", "X", " ", " ", "Z", " ", "Y", " "]

```

I am writing a function that will result in 

```
list_ = [" ", " ", " ", " ", " ", " ", "X", "Z", "Y"] 

```

Basically it will push all the non-empty (I'll call `" "` as empty here for simplicity) to the end of the list while retaining their orders

My solution as follow

```
def push(list_):
    def find_current_element(list_, from_):
        for i in range(from_+1, len(list_)):
            if list_[i] != " ":
                return i
        return None

    list_ = list_[::-1]
    good_index = list_.index(" ")
    current_element_index = find_current_element(list_, 0)
    while(current_element_index is not None):
        for i in range(good_index, len(list_)):
            if list_[i] != " ":
                list_[good_index], list_[i] = list_[i], " "
                good_index += 1
                current_element_index = find_current_element(list_, current_element_index)
    return reversed(list_)

```

It works, but it seems too long and using too much resource (reverse the list twice and bunch of for loops). I wouldn't care if the items were just simple character, but I plan to have some big objects as items of the list. I am wondering is there a simpler approach