Community Market Price Logger (Day 1 of 30 Days of Python)

Published: (December 31, 2025 at 08:54 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Intro

Day 1 of my 30 Days of Python: a tiny CLI that logs community market prices in Nigeria, prints prices with the naira symbol (₦), and shows the difference from the last recorded values.

  • Prompts for market name and date
  • Takes current prices for Garri and Rice
  • Stores values in a dictionary
  • Prints prices with ₦ and thousands separators
  • Compares against the last record and shows the difference

Implementation notes

  • Unicode/Encoding – Using the naira sign as \u20A6 ensures it renders even if the editor font has issues. UTF‑8 saves render ₦ fine in VS Code/GitHub.
  • f‑Strings + Quotes – Avoid nested double quotes inside f‑strings when indexing a dict. Use single quotes for keys: {food_items['garri']}. This fixes syntax errors.
  • Dictionary Keys vs Index – Access by key strings, not numeric indices, to avoid KeyError.
  • Safe Numeric Input – Convert input() to int so you can format with :, (e.g., ₦1,800).
  • Tiny UX Wins – Prefix prompts with ₦ so users know the expected unit; add blank lines for readable output.

Future ideas

  • Input validation (reject non‑numeric input gracefully)
  • Persist daily logs to CSV/JSON
  • Track more items and compute min/max/average over time
  • Add a --market and --date flag for quick logging

Call to Action

If you’re building African‑focused tools with Python, drop feedback or ideas. Stars and forks are welcome!

Back to Blog

Related posts

Read more »