Day 77単語数を数えるテキスト解析

2026-05-12 JST ・ 難易度: 初級 ・ カテゴリ: 文字列

Pythonコード

1text = 'Pythonは便利な言語です。'2words = text.split()3print('単語数:', len(words))4 5try:6    num = int(input('数字を入力してください:'))7    print('入力された数字:', num)8except ValueError:9    print('数字ではありません。')

解説

次に試してみよう