updated contents from Atlas repo
This commit is contained in:
19
interfaces/bingo.py
Normal file
19
interfaces/bingo.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import random
|
||||
|
||||
from tombola import Tombola
|
||||
|
||||
|
||||
class BingoCage(Tombola): # <1>
|
||||
|
||||
def __init__(self, items):
|
||||
self._balls = list(items) # <2>
|
||||
|
||||
def load(self, items):
|
||||
self._balls.extend(items)
|
||||
|
||||
def pop(self):
|
||||
try:
|
||||
position = random.randrange(len(self._balls)) # <4>
|
||||
except ValueError:
|
||||
raise LookupError('pop from empty BingoCage')
|
||||
return self._balls.pop(position)
|
||||
Reference in New Issue
Block a user