Iter() returned non-iterator of type

Hi,I have problem with my quiz in intermediate python 3 course and I couldnt find any solution for this error:

Traceback (most recent call last):
File “”, line 27, in
classroomiter = iter(myclassroom)
TypeError: iter() returned non-iterator of type ‘ClassroomOrganizer’

could you please help me?

this is my class code:

from roster import student_roster
import itertools
# Import modules above this line
class ClassroomOrganizer:
  def __init__(self):
    self.sorted_names = self._sort_alphabetically(student_roster)

  def __iter__(self):
    return self
  def _sort_alphabetically(self,students):
    names = []
    for student_info in students:
      name = student_info['name']
    return sorted(names)

  def get_students_with_subject(self, subject):
    selected_students = []
    for student in student_roster:
      if student['favorite_subject'] == subject:
        selected_students.append((student['name'], subject))
    return selected_students

myclassroom = ClassroomOrganizer()
classroomiter = iter(myclassroom)

your class needs to implement __next__ method, otherwise the iterator doesn’t know how to retrieve the next item. See:

Thanks,I implemented it and problem has solved,Now I dont know what NEXT has to return :)))))

this method literally needs to return the next value, so you need to track of where you are in your iteration