我正在研究将一个陈述变成问题的程序的一部分。 当我尝试删除x时,它返回none,我希望它打印删除该项目的句子,我做错了什么?
def Ask(Question):
Auxiliary = ("will","might","would","do","were","are","did")
for x in Auxiliary:
if x in Question:
Question_l = Question.lower()
Question_tk_l = word_tokenize(Question)
Aux_Rem = Question_tk_l.remove(x)
print (Aux_Rem)
需要行为的示例:
"what we are doing in the woods"
应该成为
"what we doing in the woods"
我想从问题中删除任何辅助功能。
答案 0 :(得分:1)
这是正确的行为。 function profileMouseOverLeft(e) {
profileLeftInterval = setInterval(function () {
profileMoveLeft(0);
}, 7);
}
function profileMouseOverRight(e) {
profileRightInterval = setInterval(function () {
profileMoveRight(0);
}, 7);
}
function profileMoveLeft(currentSlider) {
imagesWrapper[currentSlider].scrollLeft += -5;
}
function profileMoveRight(currentSlider) {
imagesWrapper[currentSlider].scrollLeft += 5;
}
删除该元素并且不返回值(即返回remove
)。如果您想访问已删除的元素,可以使用None
。
答案 1 :(得分:0)
somelist.remove(x)
从x
中删除它找到的等于somelist
的第一个元素。它不会返回修改后的列表。要打印修改后的列表,只需打印列表即可。
print(Question_tk_l)
如果你想把它变成一个好的字符串,你应该用空格加入它。
print(' '.join(Question_tk_l))