Question: I am using ExtJS 6 version.

I have panel element and dynamically I am updating panel html as 

```
panel.update("<img src=app/resources/first.jpg ></img>");

```

after updating html, image is not loading. I did `panel.updateLayout();` still image is not loading.

Please suggest

Answer: 
If you want the list of lines without the trailing new-line character you can use `str.splitlines()` method, which in this case you can read the file as string using `file_obj.read()` then use `splitlines()` over the whole string. Although, there is no need for such thing when the `open` function is already returned a generator from your lines (you can simply strip the trailing new-line while processing the lines) or just call the `str.strip()` with a `map` to create an iterator of striped lines:

```
with open('dictionary.txt'):
    striped_lines = map(str.strip, f)

```

But if you just want to count the words as a pythonic way you can use a generator expression within `sum` function like following:

```
with open('dictionary.txt') as f:
    word_count = sum(len(line.split()) for line in f)

```

Note that there is no need to strip the new lines while you're splitting the line.

e.g.

```
In [14]: 'sd f\n'.split()
Out[14]: ['sd', 'f']

```

But if you still want all the words in a list you can use a list comprehension instead of a generator expression:

```
with open('dictionary.txt') as f:
    all_words = [word for line in f for word in line.split()]
    word_count = len(all_words)

```
if you want to return a list of lines without `\n` and then print the length of this list:

```
def line_list(fname):
    with open(fname) as file:
        return file.read().splitlines()

word_list = line_list('dictionary.txt')  # 1 word per line
print(len(word_list))

```