Find Index in List

Given a list of integers and a target integer, write a Python program to find the index of the target integer in the list.

Example 1:

Input: [1,2,3,4,5], 3 
Output: 2

Example 2:

Input: [10,20,30,40,50], 40 
Output: 3

Use Python’s built-in index() function for lists.

def find_index(nums, target):
    return nums.index(target)

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!