【发布时间】:2020-02-26 20:05:18
【问题描述】:
所以基本上它会是这样的:
MyList=["Monkey","Phone","Metro","Boom","Feet"]
假设我的输入是 m 所以 Boom 和 Monkey 和 Metro 会像这样放在一个列表中
output >> ["Monkey","Metro","Feet"]
如果我将输入设为 f,那么输出将是
output >> ["Feet"]
我的问题是如何将其放入 def 中?这就是我想出来的
def Find(word,MyList):
MyList2=[]
count=0
for i in MyList:
count+=1
if i[count] == MyList2: ##(at first i did if i[0:10])
for x in range(1):
MyList2.append(i)
print(MyList2)
然后在某个地方应该有
word=input("Word, please.")
然后
Find(word,MyList)
提前致谢!
【问题讨论】:
-
输入字母表可以出现在 mylist 中单词的任何索引处,对吗?
标签: python python-3.x list