到目前爲止,我有...如何使用用戶輸入搜索列表?
def main():
list = [8, 25, 10, 99, 54, 3, 61, 24]
print("Your list is: ",list)
new = input("Please choose a number from the list:")
print("Your numbers index is:", list.index(new))
input("Press enter to close program")
所以我的問題是,我無法弄清楚如何利用用戶輸入,並獲得用戶的首選指標。例如,如果用戶輸入99,我的程序將返回「您的號碼索引爲:3」
請幫忙。
使用'int()'......... – devnull