我正在嘗試編寫一個程序,其中有幾個條件。我想從令牌列表中排除單詞列表(det)。高達if len(W) <=8:
,它的工作就像我想要的那樣。但是,我無法讓程序找到我的令牌列表中的任何單詞,並將它們從打印中排除。排除Python條件中的詞
這是我目前:
det = ['the','a',an','\'s']
w for w in tkV if w not in det
def BT_pos1(w):
for w in tkV:
if w.islower():
if len(w) >=3:
if len(w) <=8:
if w not in det:
print w, ' may be a bt.'
請使用Code按鈕 – 0xAX 2011-03-16 13:53:08
請通過縮進4個空格格式化代碼(按工具欄上的「{}」按鈕),並使用真實選項卡/空格代替(tab)'。 – kennytm 2011-03-16 13:53:39
什麼是tkV?你是否將發電機聲明分配給任何東西? – nmichaels 2011-03-16 13:58:13