Day 37 of 100 Days Coding Challenge: Python
I have so many morning routines now that I need a morning routine just to organize them. Somewhere between meditating, hydrating, and pretending I’ll stretch for ten minutes, I give myself about five sacred minutes to scroll headlines on Google Pixie—my beloved phone, not a whimsical AI assistant (though honestly, close). It’s funny to think how much easier it is now than in the ‘90s, when “catching up on the news” meant flipping through an actual newspaper or—if you were tech-savvy—tapping into Yahoo News. I used to wonder whether those top headlines were handpicked by real people or magically summoned by a robot in a cubicle. Well, today I decided to find out what it feels like to be that robot. Except mine runs on Python and coffee.
Today’s Motivation / Challenge
There’s something delightful about making your own mini news reader. It’s like building a personal butler who only tells you the important stuff—no ads, no clickbait, no Kardashian updates (unless you really want them). Today’s challenge wasn’t just about coding; it was about reclaiming five minutes of my day from mindless scrolling and putting a bit of personality into my news.
Purpose of the Code (Object)
This little script fetches the top headlines from the internet and displays them in your terminal—clean, fast, and focused. You don’t need to open a browser or wade through a swamp of autoplay videos. It’s just a straight shot to what’s happening in the world, courtesy of your own code.
AI Prompt:
Write a Python script that uses NewsAPI to display the top 10 headlines in the terminal. Use environment variables for the API key. Keep the script simple and readable.
Functions & Features
- Connects to NewsAPI and fetches top news headlines
- Displays each headline and a brief description (if available)
- Includes clickable links for more information
- Clean, readable terminal output
Requirements / Setup
- Python 3.x
Install these packages:
pip install requests python-dotenv
Minimal Code Sample
from dotenv import load_dotenv
import os, requests
load_dotenv()
api_key = os.getenv(“NEWS_API_KEY”)
response = requests.get(“https://newsapi.org/v2/top-headlines”, params={
“country”: “us”, “apiKey”: api_key, “pageSize”: 10
})
for article in response.json()[“articles”]:
print(article[“title”])
This snippet grabs the top 10 headlines and prints their titles. Simple and effective.
Notes / Lessons Learned
The coding went suspiciously smoothly today—almost unsettling. I finally did what every tutorial whispers about but no one actually does: I created a dedicated virtual environment. Then I installed the required libraries like a responsible adult. Getting an API key from newsapi.org was straightforward, and I even tucked it safely into a .env file (no more hardcoded sins). .gitignore? Created. requirements.txt? Generated with pride. After a few past failures, I’m beginning to feel like I almost know what I’m doing. It’s like learning to ride a bike, except the bike is made of code and occasionally throws a syntax error.
Optional Ideas for Expansion
- Add voice support using pyttsx3 to read headlines aloud (hello, audio butler)
- Let the user filter headlines by category (e.g., sports, tech, science)
- Include headlines from multiple countries using user input

