for x in a:
if x[1] in NERTagger:
kata = ''
kt = NERTagger[x[1]]
for y in a:
if x[0] is not y[0]:
kata += y[0] + ' '
elif x[0] == y[0]:
kata += kt + ' '
hasil.append(kata)
How to transform the code above into the while-loop? because there is an if and for-loop again in the code
x[0] is not y[0]may not do what you think.istests for object identity, not value equality. Try this:s='a'; print('ab' is s+'b')isis the correct operator (but perhaps not the indexing); note that bothxandyiterate overa. But mixingisand==deserves a comment at least, they are not complementary (in which caseelsewould do anyway).while? It's almost always better withforin Python, and I don't see a clear reason in the code.elsemakes me suspect that they don't.