linear search in python programming -


i have wriiten code linear search in python language. code working fine single digit numbers not working double digit numbers or numbers more that. here code.

def linear_search(x,sort_lst):     = 0     c= 0     in range(len(sort_lst)):         if sort_lst[i] == x :              c= c+1     if (c > 0):       print ("item found")     else :        print ("not found") sort_lst= input("enter array of numbers:") item= input("enter number searched :") linear_search(item,sort_lst) 

any suggestions ?

replace

sort_lst= input("enter array of numbers:") 

with:

print 'enter array of numbers:' sort_lst= map(int, raw_input().strip().split(' ')) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -