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

Problem 26: Counting Words

A sequence of English words separated by half-width spaces is given on one line from standard input. Print, on one line, how many words there are.

For example, for I love python, there are 3 words, so print 3.

Constraints

1 ≤ total length ≤ 200, number of words is 1 or more

Input example 1

I love python

Output example 1

3

Input example 2

hello

Output example 2

1

What you'll train

Specify the input

What you get

  • Specify the delimiter character
  • Write how to handle consecutive spaces
  • Make the input format explicit

How to ask the AI

Tell the AI that the input is a single line separated by half-width spaces, and whether there might be extra spaces between words. Being mindful of how split behaves and checking with concrete examples helps put your mind at ease.

If you ask vaguelyIf the input format is left ambiguous, the AI may write code that assumes line breaks or commas as separators.

あなたのコード

実行しました

プレビュー

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

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

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