<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def assigned_state(instance):
 """Returns `assigned` or `unassigned` depending on the state of the analyses the analysisrequest contains. Return `unassigned` if the Analysis Request has at least one analysis in `unassigned` state. Otherwise, returns `assigned` """

    analyses = instance.getAnalyses()
    if not analyses:
        return "unassigned"
    for analysis in analyses:
        analysis_object = api.get_object(analysis)
        if not analysis_object.getWorksheet():
            return "unassigned"
    return "assigned"