蟒蛇新手。所以我有这个函数,我不知道如何让它接受两个参数并将其返回到另一个列表中,并附上它们的位置。在主程序中,我希望它调用 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()