CodeDrill
day_streak: --
← 問題一覧に戻る
Python ・ Standard I/O

Problem 60: How Many Times Does the Given Word Appear?

A sentence with words separated by spaces is given on the first line, and a word W is given on the second line. When the sentence is split into words, output how many words exactly match W. (ab and abc do not match.)

Constraints

The sentence has between 1 and 50 words; each word and W consist of lowercase letters only, 1 to 20 characters long

Input example 1

the cat and the dog
the

Output example 1

2

Input example 2

a b c
d

Output example 2

0

What you'll train

State the constraints

What you get

  • Specify the exact-match condition
  • Make the splitting method explicit
  • Excluding partial matches

How to ask the AI

Clearly tell the AI the condition that partial matches like "ab" within "abc" should not be counted — only words that exactly match should be counted.

If you ask vaguelyChecking whether the string is contained within another, causing "ab" inside "abc" to be counted as a match.

あなたのコード

実行しました

プレビュー

AIレビュー(プロンプト練習)

コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。

先にコードを実行し、テストを1つ以上通してください。