python新增功能。所以我有这个功能,而且我不知道如何让它取两个参数并将它返回到另一个列表中。主要程序中的 我希望它调用x在列表中搜索,并将它发生的地方打印出来。 我是否以正确的方式开展工作? 这是我想出来的。 会真正感谢帮助 在此先感谢。我如何获得一个函数来接受两个参数?
def find_multiple():
arg1 = input(" L: ")
arg2 = input(" x: ")
return L
def main():
L = [4, 10, 4, 2, 9, 5, 4 ]
x = int(input("Enter an element to search for in the list: "))
if (len(L_indexes) == 0):
print(x, " does not occur in L.")
L =[]
results = L
print("enter an element to search for in the list: ")
if(len(L) == 0):
print("element does not occur in the list")
else:
print("the number of occurrences in L: ", x)
main()
你知道如何获得一个函数来接受一个参数吗? – JBernardo
这可能是一个好主意,通过教程... http://docs.python.org/2/tutorial/controlflow.html#defining-functions – monkut