Last active
March 20, 2018 22:24
-
-
Save jordanhudgens/393d2536c3580955248b81b6ea036a43 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Lineup: | |
def __init__(self, players): | |
self.players = players | |
def __iter__(self): | |
self.n = 0 | |
return self | |
def __next__(self): | |
if self.n < (len(self.players) - 1): | |
player = self.players[self.n] | |
self.n += 1 | |
return player | |
elif self.n == (len(self.players) - 1): | |
player = self.players[self.n] | |
self.n = 0 | |
return player | |
astros = [ | |
'Springer', | |
'Bregman', | |
'Altuve', | |
'Correa', | |
'Reddick', | |
'Gonzalez', | |
'McCann', | |
'Davis', | |
'Tucker' | |
] | |
astros_lineup = Lineup(astros) | |
process = iter(astros_lineup) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) | |
print(next(process)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment