<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def onlylegalchar(name):
 """return only legal chars"""

    legalchar = ascii_letters + digits + ' '
    return ''.join([s for s in name[:] if s in legalchar])