Python Forum
Error TypeError: '<=' not supported between instances of 'int' and 'NoneType'
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error TypeError: '<=' not supported between instances of 'int' and 'NoneType'
#1
Hello,

I am new to python and working on the creating client of websocket API. In One function I am getting the error
[b]if 3000 <= code < 4000:
Output:
TypeError: '<=' not supported between instances of 'int' and 'NoneType'[/b]
the complete error is

*********************
Error:
Traceback (most recent call last): File "c:\Users\Development\Documents\Python\WebSocket\WebsocketSample_Phython.py", line 577, in <module> asyncio.get_event_loop().run_until_complete(functionCall()) File "C:\Users\Development\AppData\Local\Programs\Python\Python36-32\lib\asyncio\base_events.py", line 468, in run_until_complete return future.result() File "c:\Users\Development\Documents\Python\WebSocket\WebsocketSample_Phython.py", line 569, in functionCall await GetInstruments() File "c:\Users\Development\Documents\Python\WebSocket\WebsocketSample_Phython.py", line 453, in GetInstruments response = await websocket.recv() File "C:\Users\Development\AppData\Local\Programs\Python\Python36-32\lib\site-packages\websockets\protocol.py", line 323, in recv raise ConnectionClosed(self.close_code, self.close_reason) File "C:\Users\Development\AppData\Local\Programs\Python\Python36-32\lib\site-packages\websockets\exceptions.py", line 147, in __init__ if 3000 <= code < 4000: TypeError: '<=' not supported between instances of 'int' and 'NoneType'
*********************

How can I fix this?

Thanks and regards
Dhananjay Kale
Reply
#2
Hi, next time please use proper tags for formating the post, you can find help here.

The error message suggests that the code variable holds a None value, which obviously cannot be compared to a number. So check the rest of your program to find how code becomes None. It could be you intended to assign code a result of a function with no return statement. By default functions return None. If you are unsure, post the rest of your code in Python code tags.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 444 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 677 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 916 Aug-24-2023, 05:14 PM
Last Post: snippsat
  boto3 - Error - TypeError: string indices must be integers kpatil 7 1,181 Jun-09-2023, 06:56 PM
Last Post: kpatil
  Getting "SSL client not supported by this Python installation" error prabirsarkar 0 914 Mar-13-2023, 05:01 PM
Last Post: prabirsarkar
  'NoneType' error YL1985 9 2,361 Nov-26-2022, 08:45 PM
Last Post: Yoriz
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 1,857 Oct-17-2022, 06:29 PM
Last Post: paulo79
  TypeError: 'NoneType' object is not subscriptable syafiq14 3 5,160 Sep-19-2022, 02:43 PM
Last Post: Larz60+
  "<class 'typeerror'>: don't know how to convert" error GiggsB 3 3,236 Feb-28-2022, 06:45 PM
Last Post: GiggsB
  TypeError: sequence item 0: expected str instance, float found Error Query eddywinch82 1 5,023 Sep-04-2021, 09:16 PM
Last Post: eddywinch82

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020