if api_version>4:
error_code=35
response_body=correlation_id.to_bytes(4,‘big’) + error_code.to_bytes(2,‘big’)
else:
error_code=0
response_body=b’’
response_body+=correlation_id.to_bytes(4,‘big’)
response_body+=error_code.to_bytes(2,‘big’)
response_body+=(1).to_bytes(4,'big') #number of api keys
response_body+=(18).to_bytes(2,'big') #fix for api versions
response_body+=(0).to_bytes(2,'big') #min version
response_body+=(4).to_bytes(2,'big') #max version
response_body+=(0).to_bytes(4,'big') # throttle_time_ms
response_body += (0).to_bytes(1, 'big')
response_length=len(response_body).to_bytes(4,'big')
response=response_length + response_body
conn.sendall(response)
so basically this is my condition statement to send code i am always getting error for unexpected end for the data what could be the solution i wrote the format in correct way