code: def prev_next_group(project, group):
      groups = sorted(x for x in project.groups if x.submissions)
      try:
          index = groups.index(group)
      except ValueError:
          return None, None
      prev_group = groups[index - 1] if index > 0 else None
      next_group = groups[index + 1] if index + 1 < len(groups) else None
      return prev_group, next_group