The searchQueryForm() function return None value and len() in-build function not accept None type argument. So Raise TypeError exception.
Demo:
>>> searchList = None
>>> print type(searchList)
<type 'NoneType'>
>>> len(searchList)
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: object of type 'NoneType' has no len()
Add one more condition in if loop to check searchList is None or not
Demo:
>>> if searchList==None or len(searchList) == 0:
... print "nNothing"
...
nNothing
return statement is missing in the searchQueryForm() function when code is not go into last if loop. By default None value is return when we not return any specific value from function.
def searchQueryForm(alist):
noforms = int(input(" how many forms do you want to search for? "))
for i in range(noforms):
searchQuery = [ ]
nofound = 0 ## no found set at 0
formname = input("pls enter a formname >> ") ## asks user for formname
formname = formname.lower() ## converts to lower case
for row in alist:
if row[1].lower() == formname: ## formname appears in row2
searchQuery.append(row) ## appends results
nofound = nofound + 1 ## increments variable
if nofound == 0:
print("there were no matches")
return searchQuery
return []
# ^^^^^^^ This was missing
read_csvandsearchQueryForm(myList).searchQueryForm()is missing return statement. And please fix indentation.searchQueryForm()function returnNonevalue,