The for loop her needs to ignore empty strings.
There's a number of ways to check for this, the easiest of this would likely be ensuring the x.strip() method doesn't return a null value, like so.
for x in split_text:
if not x.strip():
continue
counter += 1
sentence = x.split(' ')
sen_total.append(len(sentence))
Otherwise, I would also recommend giving yourself a more descriptive variable name when iterating through split_text. Something like "line".
The for loop her needs to ignore empty strings. There's a number of ways to check for this, the easiest of this would likely be ensuring the x.strip() method doesn't return a null value, like so. for x in split_text: if not x.strip(): continue counter += 1 sentence = x.split(' ') sen_total.append(len(sentence))
Otherwise, I would also recommend giving yourself a more descriptive variable name when iterating through split_text. Something like "line".