[英]How can I remove specific members from the list in python?
this is my code, I want to know where the problem is with this code And also, instead of removing and, no, i from the list;这是我的代码,我想知道这段代码的问题出在哪里而且,而不是从列表中删除 and,不,i; replace it with a number.
用数字替换它。
word = input("your sentece in english : ")
Word = word.split()
Word = word.lower()
new_word = ""
delet = ["and","no","i"]
print(Word)
for m in Word:
if m not in delet:
new_word = new_word + m
print(new_word)
尝试使用enumerate
,
for index, m in enumerate(Word): if m in delet: Word[index] = int
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.