Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the task: Write a function to take a list of numbers and a number to check if the number is in the list

This is the task:

Write a function to take a list of numbers and a number to check if the number is in the list or not.

Print out the index of the element, if it exists in the list, and the message 'The element does not exist in the list', otherwise.

This is my code:

image text in transcribed

How can i change my code to avoid using the list built in functions for finding elements? (This is python coding language)

\#\#Your code here list 1=[1,2,3,5,6,9,12,34,38,45,49] def functionName (x) : result =[] for index in range(len(list 1)) : if x in 1 ist 1 : i= ist 1. index (x) result.append (i) print (result, x ) else: print('The element does not exist in the list') return functionlare (38) [8] 38

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions