Question: I'm trying to run a command using `subprocess.check_call()`, but it appears from the output that the parameters I'm giving are not interpreted as a string but as a char list.
The command I'm trying to run: `7z x test.rar`.
What actually is running:

`subprocess.CalledProcessError: Command '['7z', 'x', 't', 'e', 's', 't', '.', 'r', 'a', 'r']` returned non-zero exit status 2.

For some reason, the file name is separated in the characters. What am I missing?

The code:

```
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("input", help="File/Folder to extract")
    args = parser.parse_args()
    extract_file(args.input)

def extract_file(file):
    extract_cmd = ['7z']
    extract_cmd.extend('x')
    extract_cmd.extend(file)
    subprocess.check_call(extract_cmd)

```

Answer: 
`setTimeout` in a `for` loop runs after the for loop execution completed. so, you always see the last value. to solve this, you can use `$.each` method which provides a callback function or use an Immediately Invoked Function Expression. 

more detailed info: <https://codehandbook.org/understanding-settimeout-inside-for-loop-in-javascript/>

```js
var data=[];
for(var i=0; i<10; i++){
  data.push(i+' lorem ipsum doloret');
}

$.each(data, function(i, el){

    setTimeout(function(){
         $("#replaceMe").replaceWith('<pre id="replaceMe">' + data[i] + '</pre>');
    },500 + ( i * 1000 ));

});
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<pre id="replaceMe">***</pre>
```
You can do that using setInterval function:

```
var words = ['interating', 'and', 'replacing', 'text'];
var replace = document.querySelector('#replace');
var count = 0;

function replaceText() {
  replace.innerHTML = words[count];
  if(count === words.length - 1)
    count = 0;
  else
    count++;
}

setInterval(replaceText, 1000);

```

---

Updating:
You don't need to replace all the element, you can replace only the content, using the atribute innerText.