(connection, lower, upper, secret)
| 148 | |
| 149 | @contextlib.contextmanager |
| 150 | def new_game(connection, lower, upper, secret): |
| 151 | print( |
| 152 | f"Guess a number between {lower} and {upper}!" |
| 153 | f" Shhhhh, it's {secret}." |
| 154 | ) |
| 155 | connection.send(f"PARAMS {lower} {upper}") |
| 156 | try: |
| 157 | yield ClientSession( |
| 158 | connection.send, |
| 159 | connection.receive, |
| 160 | secret, |
| 161 | ) |
| 162 | finally: |
| 163 | # Make it so the output printing matches what you expect |
| 164 | time.sleep(0.1) |
| 165 | connection.send("CLEAR") |
| 166 | |
| 167 | |
| 168 | print("Example 9") |
no test coverage detected