-2

I am having trouble with convert this single line loop into multiple line code in python.

text_data = [''.join(char for char in sent if char not in punct) for sent in text_data]

Thanks in advance.

UPDATE

solved it.

out_list = []
for sent in test_data:
    out_str = ''
    for char in sent:
        if char not in punct:
            out_str = out_str+char
    out_list.append(out_str)

thanks for the help

1 Answers1

0

you can try following snippet for your nested one line for loop

out_list = []
for sent in text_data:
    out_str = ''
    for char in sent:
        if char not in punct:
            out_str.join(char)
    out_list.append(out_str)
Ravi
  • 1
  • 1