| about | help | code help+videos | done | prefs |
Write a function named index_of that returns the index of a particular value in a list of integers. The function should return the index of the first occurrence of the target value in the list. If the value is not in the list, it should return -1. For example, if a list called list stores the following values: list = [42, 7, -9, 14, 8, 39, 42, 8, 19, 0] Then the call index_of(list, 8) should return 4 because the index of the first occurrence of value 8 in the list is at index 4. The call index_of(list, 2) should return -1 because value 2 is not in the list. index_of([42, 7, -9, 14, 8, 39, 42, 8, 19, 0], 8) → 4 index_of([42, 7, -9, 14, 8, 39, 42, 8, 19, 0], 2) → -1 index_of([74, 85, 102, 99, 101, 85, 56], 85) → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290 Post-solution available
Copyright Nick Parlante 2017 - privacy