plete the following function according to its docstring using a while loop. The lists we test will not all be sho cribed in English. If you fail any test cases, you will need to read the description and make your own test. def smaller_index(items: list[int]) -> int: Return the index of the first integer in items that is less than its index, or -1 if no such integer exists in items. 6. >>> smaller_index([2, 5, 7, 99, 6]) -1 8 >>> smaller_index([-5, 8, 9, 16]) 9. 10 >>> smaller_index([5, 8, 9, 0, 1, 3]) 11 3 12 for i in range (len(items)): if items[i] < i: 13 14 15 return i 16 return -1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
icon
Related questions
Question
hdex
mplete the following function according to its docstring using a while loop. The lists we test will not all be sho
cribed in English. If you fail any test cases, you will need to read the description and make your own test.
def smaller_index(items: list[int]) -> int:
3\
Return the index of the first integer in items that is less than its index,
4.
or -1 if no such integer exists in items.
6.
>>> smaller_index([2, 5, 7, 99, 6])
7.
-1
8
>>> smaller_index([-5, 8, 9, 16])
9.
10
>>> smaller_index([5, 8, 9, 0, 1, 3])
11
3
12
for i in range (len(items)):
if items [i] < i:
13
14
15
return i
16
return -1
History
X Your solution passed 0 out of 6 cases!
Transcribed Image Text:hdex mplete the following function according to its docstring using a while loop. The lists we test will not all be sho cribed in English. If you fail any test cases, you will need to read the description and make your own test. def smaller_index(items: list[int]) -> int: 3\ Return the index of the first integer in items that is less than its index, 4. or -1 if no such integer exists in items. 6. >>> smaller_index([2, 5, 7, 99, 6]) 7. -1 8 >>> smaller_index([-5, 8, 9, 16]) 9. 10 >>> smaller_index([5, 8, 9, 0, 1, 3]) 11 3 12 for i in range (len(items)): if items [i] < i: 13 14 15 return i 16 return -1 History X Your solution passed 0 out of 6 cases!
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning