在列表中的元組的大小爲39如何僅使用python打印輸出1次?
這裏是我的代碼:
def joinphrase(joinph,i):
length = len(joinph)
res = ['%s %s' % (joinph[i][0], joinph[i + 1][0])
for i in range(length)
if i < length - 1 and joinph[i][2] == 'B-NP' and joinph[i + 1][2] == 'I-NP']
return res
def sentjoinphrase(joinph):
return [joinphrase(joinph, i) for i in range(len(joinph))]
example = test_sents[0]
print (sentjoinphrase(example))
我想加入從不同的元組兩個字符串的條件和打印輸出連接。但是根據列表中元組的大小,輸出打印了39次。
如何僅打印輸出1次?
你能告訴我們你所指的元組嗎? –