Skip to content
Advertisement

How do I read the following lines of code?

Apologies for the basic question as I am quite new to the topic.

 conlltags = [(word, pos, chunktag) for ((word,pos),chunktag)
                     in zip(sentence, chunktags))]

Can you please break the code above in the format given below:

for i in exampleSentence:
    letterByLetter = i
    print(letterByLetter)

Advertisement

Answer

I think it is better for you to look up the following subjects:

  • List comprehensions – link
  • zip() function – link

This will give you a better understanding of what is happening and it is very useful to use in one of your future projects!

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement