Skip to content
This repository was archived by the owner on Mar 14, 2022. It is now read-only.

[Homework 4] 文句處理 #375

@panda44967

Description

@panda44967

提交連結

https://judge.ccclub.io/contest/83/problem/01

程式碼

#輸入關鍵字及文章內容
keyword=input().split()
keywords=keyword.copy()
content=""
while True:
    text_here=input()
    if text_here=='end':
        content=content[:-1]
        break
    else:
        content=content+text_here+"\n"
# 處理關鍵字 eg. apple, app,請以長度較長的關鍵字為先
  # 用i和j兩個一樣內容的迴圈進行判斷,是為了做兩兩相比        
for i in keyword:
    for j in keywords:
        if i in j and (len(i))<(len(j)):
            keyword.remove(i)  # 若有相同且字串長度比較小的,就把它從關鍵字中移除
#看每個關鍵字是否有在文章中,如果有,用replace加上引號
for i in keyword:
    if i in content:
        content=content.replace(i,"「"+i+"」")
print(content)

錯誤訊息

Runtime Error

問題描述

測資在Jupyter上都對,不確定問題在哪?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions