There is a code, its meaning is as follows: The user enters variables (query, where) to search the local database, the code looks for the ResID in the database using the passed variables, and displays the information received by the user, So it turns out that not one in the database can fall out ResID, and the user is given a brief information about the record in the database, and asks you to choose the one you need, and while if you enter 1 ResID when entering variables, everything goes perfectly and the record is shown, but if more than 1 record appears, Python recognizes in the function (func4) "NoneType" object, and drops out I don’t understand what the problem is, I learned experimentally that func4 and if 1 ResID, and if more than one is NoneType, but in the 1st case it is successfully executed, but not in the 2nd

Probable part of the error code:

def func0(message): global where global resID sumresid = func1(query, where) # Возвращает ВСЕ найденные resID if len(sumresid) > 1: bot.send_message(message.chat.id, 'Info:') bot.send_message(message.chat.id, 'Results: ' + str(len(sumssid))) bot.register_next_step_handler(message, IPMO(message, sumresid)) # если найдено больше 1 resID, передаёт список функции IPMO которая показывает все найденные записи, и даёт выбрать нужную пользователю. else: resID = func2(query, where) # Если найден был только 1 resID, возвращает resID compRes(message) def IPMO(message, listOfresID): sumresid = listOfresID num = 0 while True: print('DEBUG: sumResID: ' + str(sumresid)) if str(sumresid) == '[]': print('DEBUG: IF construct (str(sumresid) == "[]") is Called!') bot.send_message(message.chat.id, 'Choice profile (enter resID):') bot.register_next_step_handler(message, IPMO_Choice) break print('DEBUG: While is Working!') readyResID = sumresid[0] # Берёт 1 ResID из списка resultuple = func3(readyResID) # Возвращает tuple с данными по ResID resid = resultuple[0] var1 = resultuple[1] var2 = resultuple[2] var3 = resultuple[3] bot.send_message(message.chat.id, '[ ! ]: Result #' + str(num)) bot.send_message(message.chat.id, 'ResID: ' + ssid) bot.send_message(message.chat.id, 'Var1: ' + var1) bot.send_message(message.chat.id, 'Var2: ' + var2) bot.send_message(message.chat.id, 'Var3: ' + var3) num = num + 1 sumresid.remove(sumresid[0]) def IPMO_Choice(message): print('DEBUG: Called local func: IPMO_Choice') global ResID ResID = message.text debugCheckResID() compRes(message) def debugCheckResID(): # Придумана чисто для теста print('DEBUG: Called local func: debugCheckResID') print('DEBUG: Selected ResID: ' + ResID) def compRes(message): print('DEBUG: Called local func: compRes') print('DEBUG: Type of func Func5: ' + str(type(mainInfoResult()))) # Результат: DEBUG: Type of func Func4: <class 'NoneType'> bot.send_message(message.chat.id, 'ResID found! (' + ResID + ')') bot.send_message(message.chat.id, 'Compiling result...') Func4() bot.send_message(message.chat.id, 'Func4...COMPILED!') 

Here is what Traceback returns:

 Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/telebot/util.py", line 59, in run task(*args, **kwargs) TypeError: 'NoneType' object is not callable" Traceback (most recent call last): File "bot.py", line 1587, in <module> bot.polling(none_stop=True, timeout=60) File "/usr/local/lib/python3.5/dist-packages/telebot/__init__.py", line 389, in polling self.__threaded_polling(none_stop, interval, timeout) File "/usr/local/lib/python3.5/dist-packages/telebot/__init__.py", line 413, in __threaded_polling self.worker_pool.raise_exceptions() File "/usr/local/lib/python3.5/dist-packages/telebot/util.py", line 108, in raise_exceptions six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2]) File "/usr/lib/python3/dist-packages/six.py", line 686, in reraise raise value File "/usr/local/lib/python3.5/dist-packages/telebot/util.py", line 59, in run task(*args, **kwargs) TypeError: 'NoneType' object is not callable 

    0