<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_legend(self, legend):
 """legend needs to be a list, tuple or None"""

        assert(isinstance(legend, list) or isinstance(legend, tuple) or
            legend is None)
        if legend:
            self.legend = [quote(a) for a in legend]
        else:
            self.legend = None