def keypress_handler(e): if 1 <= int(e.keysym) <= 4: ship_size = int(e.keysym) return ship_size print(keypress_handler(3))