DEV Community

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

Building for local problems, one day at a time.

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.

What It Does

  • 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 last record and shows the difference

What I Learned (Debugging 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 fixed my syntax error.
  • 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.

Next Steps

  • 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

See the Demo

  • Here is a Screenshot showing:

  • Running the script

  • Entering prices

  • The formatted ₦ output and price differences

Call to Action

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

Top comments (0)