Posts

Showing posts from September, 2020

List Examples

  List Searching  pos = -1 def search1(list1,n):         i = 0         while i<len(list1):                 if list1[i] == n:                         globals()['pos']=i                         return True                 i =i+1         return False l = [1,2,3,4,50] print(l) n = int(input('enter the number to find the list: ')) if search1(l,n):         print('found',pos) else:         print('not found',pos) About log :     User will enter the value to find in the list.     Create the search function     While loop       Finding the index is using  When  globals()  is called from a function or method, it returns the di...