<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def delegate(self, to, steempower):
        ''' Delegates based on Steem Power rather
        than by vests.
        '''
        self.global_props()
        vests = self.util.sp_to_vests(steempower)
        strvests = str(vests)
        strvests = strvests + " VESTS"
        try:
            self.steem_instance().commit.delegate_vesting_shares(to, 
                                                                strvests, 
                                                                account=self.mainaccount)
        except Exception as e:
            self.msg.error_message("COULD NOT DELEGATE " 
                                    + str(steempower) + " SP TO " 
                                    + to + ": " + str(e))
            return False
        else:
            self.msg.message("DELEGATED " + str(steempower) + " STEEM POWER TO " + str(to))
            return True