Problem 123001 · easy · Level 01 Prerequisites & Setup

Find the Position

lists · searching · indexing

A seating chart is a list of names in order. Write find_position(names, target) that returns the index of the first occurrence of target, or -1 if the name is not on the chart.

Examples

Input:  names = ["ana", "bo", "cy"], target = "bo"
Output: 1

Input:  names = ["ana", "bo"], target = "zed"
Output: -1

Constraints

  • 0 <= len(names) <= 5000

Goals

  • Find the index of the first matching item
  • Return -1 when nothing matches
Starting Python…