The lobby screen looks up player names by ID. An unknown ID should show a fallback label; a broken player directory should still report its error.
A try block surrounds the operation that may fail. except KeyError handles a missing dictionary key, while a different exception still reaches the caller. Keep the block small so a programming mistake elsewhere is not mistaken for missing data. The supplied directory may be any object that supports square-bracket lookup.
Do not test the looked-up value with an if statement. An empty string can be a legitimate label, and the contract says to return it unchanged. The fallback is about an exception during lookup, not about whether the result is truthy.
The map uses a default marker for a location without one. Other lookup failures still reach the caller.
def find_marker(markers, location):
try:
return markers[location]
except KeyError:
return "unmarked"
player_label(directory, player_id) to return directory[player_id], or "Unknown player" only when lookup raises KeyError. Let other exceptions propagate.Edit main.py, then press Run. The supplied probe catches unfinished-code errors so you can inspect the Console before submitting. The finished probe prints Unknown player. Press Submit to check the behavior with other inputs.
Catch KeyError, not Exception.