-2
for l in f:
    w1, w2 = l.strip().split('\t')

I'm doing computerized text analysis in Python. This is the original code for splitting bigram elements (words) in a list of bigrams deemed significant (and the overall code is of course longer and incorporates appending the words later, but this is the problematic part of it). For bigrams it works perfectly, but I would like to implement this also for ngrams of more word elements like trigrams and fourgrams. But of course

for l in f:
    w1, w2, w3, w4 = l.strip().split('\t')

doesn't work.

What would be a good alternative in this scenario?

Thank you for the answers in advance!

  • 1
    what do you do with those words? because maybe you don't even need them as variables, just use the returned list – Matiiss Oct 18 '22 at 07:01
  • 1
    Hi, your question is not very clear, but you can try using a list rather than separate variables: `parts = l.split('\t')` – gog Oct 18 '22 at 07:01

1 Answers1

0
a,b,c,d=text.split("somethin")

#but that makes no sense

texet_parts_as_list=text.split("somethin")