Smaller index Complete the following function according to its docstring using a while loop. The lists we...

60.1K

Verified Solution

Question

Programming

Smaller index

Complete the following function according to its docstring usinga while loop. The lists we test will not all be shown; instead,some will be described in English. If you fail any test cases, youwill need to read the description and make your own test.

def smaller_index(items):
\"\"\" (list of int) -> int
  
Return the index of the first integer in items that is less thanits index,
or -1 if no such integer exists in items.
  
>>> smaller_index([2, 5, 7, 99, 6])
-1
>>> smaller_index([-5, 8, 9, 16])
0
>>> smaller_index([5, 8, 9, 0, 1, 3])
3
\"\"\"

Answer & Explanation Solved by verified expert
4.2 Ratings (909 Votes)
def smallerindexitems list of int intReturn the index    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students