{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "0a8280c70cfd4d1da288432aa3ef5f8e",
  "keywords": "散列表,散列表,算法中阶,数据结构",
  "title": "根据指定值从一个列表中查找所有匹配元素的位置，要求使用列表中的index方法进行查找。",
  "desc": [
    {
      "content": "\n<p><strong>题目内容&#xff1a;</strong>\n编写程序实现以下功能&#xff1a;根据指定值从一个列表中查找所有匹配元素的位置&#xff0c;要求使用列表中的index方法进行查找。\n<strong>输入格式:</strong>\n先输入待查找元素的值。\n再输入一个整数&#xff0c;表示列表中的元素个数。\n最后依次输入列表中的元素。\n<strong>输出格式&#xff1a;</strong>\n输出一个列表&#xff0c;各元素值为匹配元素的位置。如果没有匹配元素&#xff0c;则输出一个空列表。\n<strong>输入样例&#xff1a;</strong>\n10\n5\n5\n10\n15\n10\n20\n<strong>输出样例&#xff1a;</strong>\n[1, 3]\n<strong>输入样例&#xff1a;</strong>\n30\n5\n5\n10\n15\n10\n20\n<strong>输出样例&#xff1a;</strong>\n[]</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "check = input()\nnum = int(input())\nlist1 = []\nfor i in range(num):\n\tx = input()\n\tlist1.append(x)\nindices = []\nstart = 0\nwhile 1:\n\ttry:\n\t\tx = list1.index(check,start)\n\t\tindices.append(x)\n\t\tstart = x+1\n\texcept:\n\t\tbreak\nprint(indices)",
    "language": "python"
  },
  "node_id": "dailycode-1dc9532947e14e2aaa9274f1ba3e093e",
  "license": "csdn.net",
  "created_at": 1637894161,
  "topic_link": "https://bbs.csdn.net/topics/600469987"
}