def searchQueryForm(alist):
noforms = 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
我想用一個變量來設置循環發生的次數。我試圖通過輸入一個變量來設置它。但我不斷收到此錯誤使用一個循環,同時使用一個變量來設置它循環的次數
TypeError: 'str' object cannot be interpreted as an integer
這是發佈錯誤的完整回溯幫助的地方。你的錯誤不涉及'nofound',但它實際上涉及'noforms'。 – TerryA
您不會通過刪除所有代碼來改善您的問題。根據要求,通過發佈回溯來改進它。 –
如果答案沒問題,請接受它@Rasnaam Tiwana –