Linear Search in Python

Source code :

for i in range(0,len(elements)): 
    if num==elements[i]: 
        print(str(num) + " found at position " + str(i)) 

Output :

9 found at position 1

Algorithm :

  1. List the numbers in array
  2. Specify the number or get the input from the user which number need to find
  3. Use for loop to find the length of the elements in the list
  4. Use if condition to find the number is present in the element array
  5. Finally print the result

Output :


Comments :