Man O War - Къде съм сгрешил? Моля? Гърми на 7 и 8 тест!
def fire(index, damage, warship): warship[index] -= damage if warship[index] <= 0: return True def defend(start_index, end_index, damage, pirate_ship): for i in range(start_index, end_index + 1): pirate_ship[i] -= damage if pirate_ship[i] <= 0: return True def repair(index, health, pirate_ship, health_capacity): pirate_ship[index] += health if pirate_ship[index] > health_capacity: pirate_ship[index] -= pirate_ship[index] - health_capacity def status(pirate_ship, health_capacity): count = 0 for section in pirate_ship: if section < 0.2 * health_capacity: count += 1 print(f"{count} sections need repair.") pirate_ship = list(map(int, input().split(">"))) warship = list(map(int, input().split(">"))) max_health_capacity = int(input()) winner = False while True: command = input().split() if command[0] == "Retire": break elif command[0] == "Fire": if 0 <= int(command[1]) <= len(warship) - 1: winner = fire(int(command[1]), int(command[2]), warship) if winner: print("You win! The enemy ship has sunken.") break elif command[0] == "Defend": if 0 <= int(command[1]) <= len(pirate_ship) - 1 and 0 <= int(command[2]) <= len(pirate_ship) - 1: winner = defend(int(command[1]), int(command[2]), int(command[3]), pirate_ship) if winner: print("You lost! The pirate ship has sunken.") break elif command[0] == "Repair": if 0 <= int(command[1]) <= len(pirate_ship) - 1: repair(int(command[1]), int(command[2]), pirate_ship, max_health_capacity) elif command[0] == "Status": status(pirate_ship, max_health_capacity) if not winner: print(f"Pirate ship status: {sum(pirate_ship)}") print(f"Warship status: {sum(warship)}")