Get the answers you need at Westonci.ca, where our expert community is dedicated to providing you with accurate information. Our platform offers a seamless experience for finding reliable answers from a network of experienced professionals. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

Write a function where you are given: a list of numbers "nums", a number to search for "num". Return the index of "num" in the list "nums". If "num" is not found in the list, return -1 instead.

Sagot :

The program is an illustration of functions; functions are used to represent collection of named statements

The program in Python

The function in Python where comments are used to explain each line is as follows:

#This defines the function

def checkList(nums,num):

   #This checks if num exists in nums

   if num in nums:

       #If yes, this returns the index of num

       return nums.index(num)

   #If otherwise, this returns -1

   return -1

Read more about Python programs at:

https://brainly.com/question/26497128

#SPJ1

Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.