rahulkchou

Linear Search

Mar 1st, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. films=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
  2.  
  3. position=0
  4. found="false"
  5.  
  6. searchQuery=input("SEARCH FOR: ")
  7.  
  8. for i in films:
  9.  
  10.        
  11.     if films[position] == searchQuery:
  12.         found="true"
  13.  
  14.     position=position+1
  15.    
  16.     if found=="true":
  17.         print("Your search query was found in position:",position,"!")
  18.         break
Add Comment
Please, Sign In to add comment