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