Word count is off by one when text ends with a space

Đang mở
#1 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

@accesswatch đang làm issue này rồi.

Từ ngày 8/11/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug

What happened

word_count("hello world ") returns 3. There are only two words.

What I expected

  1. A space at the end of the text shouldn't count as a word.

How to see it

  1. Run python -c "import sys; sys.path.insert(0, 'src'); import tally; print(tally.word_count('hello world '))"
  2. It prints 3.

The same happens with two spaces between words.

Ngôn ngữ chính
Python
Star
1
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Community-Access/quill-github-practice

Tất cả issue của Community-Access/quill-github-practice

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.