-1

I have a list of sentence and i have some element of this list which contains only "." (the element : ".")

Here the list :

['SECURITY TERMS.', 'This Exhibit C to between ', '.']

I would like to remove all the dot elements from the list .

My expected result is :

['SECURITY TERMS.', 'This Exhibit C to between ']

For this I try like this :

def remove_tabulation_item(sent_text):
    x='.'
    for i in range(len(sent_text) - 1, -1, -1):
        if x in sent_text[i]:
            del sent_text[i]
    return sent_text

But the problem whith this code is that is delete all the element which cotains not only "."

Can you help me please?

sanyassh
  • 8,100
  • 13
  • 36
  • 70
  • `if x in sent_text[i]` checks to see if `x` is _ANYWHERE_ in `sent_text[i]`. What you want is `if x == sent_text[i]` – Max May 10 '19 at 16:45

1 Answers1

-1

I would do it following way:

sentence = ['SECURITY TERMS.', 'This Exhibit C to between ', '.']
nodots = [i for i in sentence if i!='.']
print(nodots) # prints ['SECURITY TERMS.', 'This Exhibit C to between ']
Daweo
  • 31,313
  • 3
  • 12
  • 25