1class LockPicker_2MI0600333:
2 def __init__(self, lock):
3 self.lock = lock
4
5 def unlock(self):
6 """Unlock the locker based on the exceptions it raises"""
7 args = []
8 while True:
9 try:
10 if self.lock.pick(*args):
11 return
12 except Exception as e:
13 if e.position is None:
14 args = [None] * e.expected
15 elif isinstance(e, TypeError):
16 args[e.position - 1] = e.expected()
17 elif isinstance(e, ValueError):
18 args[e.position - 1] = e.expected
Резултат от контролното:
23/25 верни отговора.
19 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK