Python Py-使用输入打印数组的数据

Python Py-使用输入打印数组的数据,python,multidimensional-array,Python,Multidimensional Array,我正在做一篇计算机科学过去论文(NEA),我遇到了一个问题,我将数据存储在多维数组中,我请求用户输入,预期输入已经在数组中,我希望程序打印出存储输入的数组 # Array containing the ID, last name, year in, membership, nights booked, points. array = [["San12318", "Sanchez", 2018, "Silver", 1, 2500], ["Gat32119", "Gatignol"

我正在做一篇计算机科学过去论文(NEA),我遇到了一个问题,我将数据存储在多维数组中,我请求用户输入,预期输入已经在数组中,我希望程序打印出存储输入的数组

# Array containing the ID, last name, year in, membership, nights booked, points.
array = [["San12318", "Sanchez", 2018, "Silver", 1, 2500],
        ["Gat32119", "Gatignol", 2019, "Silver", 3, 7500]]

# Asking to the user to enter the ID
inUser = input("Please enter the user ID: ")

这就是我需要帮助的地方,如果输入的ID是“San12318”,我如何让程序打印出存储它的数组?

使用for循环检查列表中每个数据记录的第0个索引处的值,即ID值:

def main():
  records = [["San12318", "Sanchez",  2018, "Silver", 1, 2500],
             ["Gat32119", "Gatignol", 2019, "Silver", 3, 7500]]
  input_user_id = input("Please enter a user ID: ")
  print(find_user_id(records, input_user_id.title()))

def find_user_id(records, user_id):
  for record in records:
    if record[0] == user_id:
      return f"Found associated record: {record}"
  return f"Error no record was found for the input user ID: {user_id}"

if __name__ == "__main__":
  main()
示例用法1:

Please enter a user ID: san12318
Found associated record: ['San12318', 'Sanchez', 2018, 'Silver', 1, 2500]
Please enter a user ID: Gat42119
Error no record was found for the input user ID: Gat42119
示例用法2:

Please enter a user ID: san12318
Found associated record: ['San12318', 'Sanchez', 2018, 'Silver', 1, 2500]
Please enter a user ID: Gat42119
Error no record was found for the input user ID: Gat42119
np.argwhere(array==inUser)[0]的可能重复项