Last active
August 22, 2020 14:12
-
-
Save saumalya75/2ef8aad839c2edeb1c13a474f551855e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class House: | |
def __init__(self, name: str, symbol: str, student_list: list): | |
self.name = name | |
self.symbol = symbol | |
self.student_list = student_list | |
self.current_student_id = -1 | |
def __len__(self): | |
return len(self.student_list) | |
def __next__(self): | |
self.current_student_id += 1 | |
try: | |
return self.student_list[self.current_student_id] | |
except IndexError: | |
raise StopIteration() | |
def __iter__(self): | |
self.current_student_id = 0 | |
return self | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment