Pybites Logo Rust Platform

Word Count

Easy +2 pts

🎯 In Python, counting words is a one-liner with collections.Counter:

from collections import Counter # simplified — doesn't strip punctuation counts = Counter(s.lower().split())

In Rust, there's no Counter, but there's HashMap — and learning how to build one up is a fundamental Rust skill.

HashMap — Rust's dict

HashMap<K, V> is Rust's equivalent of Python's dict. Unlike Python where dict is a builtin, you need to import it:

use std::collections::HashMap; let mut …

Login to see the full exercise.