if result.retcode != mt5.TRADE_RETCODE_DONE: NoneType' object has no attribute 'retcode'

 
        # send a trading request
        result = mt5.order_send(request)
        # check the execution result
        print("1. order_send(): by {} {} lots at {} with deviation={} points".format(x,lot,price,deviation));
        if result.retcode != mt5.TRADE_RETCODE_DONE:
            print("2. order_send failed, retcode={}".format(result.retcode))
            # request the result as a dictionary and display it element by element
            result_dict=result._asdict()
            for field in result_dict.keys():
                print("   {}={}".format(field,result_dict[field]))
                # if this is a trading request structure, display it element by element as well
                if field=="request":
                    traderequest_dict=result_dict[field]._asdict()
                    for tradereq_filed in traderequest_dict:
                        print("       traderequest: {}={}".format(tradereq_filed,traderequest_dict[tradereq_filed]))


NoneType' object has no attribute 'retcode'


Was the error but this is at line:

        if result.retcode != mt5.TRADE_RETCODE_DONE:

This option in the if statement is for when the order didnt go through. Did the mt5 python structure change? Whats the update way to find out if the result has failed?