DEV Community

Cover image for Random News Headline Generator in Python πŸ“°πŸ˜‚
Bilal Aslam
Bilal Aslam

Posted on

Random News Headline Generator in Python πŸ“°πŸ˜‚

Have you ever wanted to create funny, political, celebrity, or animal news headlines automatically? πŸ“°

In this post, I’ll share a simple Python project that generates random news headlines. It's beginner-friendly and a fun way to practice Python programming.


What is this project about?

The Random News Headline Generator is a Python terminal-based project that generates random headlines across four categories:

  • Funny News πŸ˜‚
  • Political News πŸ›οΈ
  • Celebrity News 🌟
  • Animal News 🐾

It’s perfect for beginners who want to:

  • Practice Python basics
  • Learn random data generation
  • Work with lists and loops
  • Create small but fun projects

Features

  • Generates random headlines in different categories
  • Simple terminal interface
  • Easy to expand with your own categories
  • Can be improved with file saving, GUI, or web interface

How it works

The project uses Python lists to store headlines and the random module to pick one randomly.

Here’s a simplified example:

import random

funny_news = [
    "Man Tries to Pay With Banana, Cashier Confused",
    "Cat Becomes Mayor of Small Town"
]

political_news = [
    "Election Results Shock Everyone",
    "Politician Forgets Speech on Stage"
]

category = input("Choose category (funny/political): ").lower()

if category == "funny":
    print(random.choice(funny_news))
elif category == "political":
    print(random.choice(political_news))
else:
    print("Category not found!")
Enter fullscreen mode Exit fullscreen mode

You can expand the lists and categories as much as you want. But For real fun you should check my code at Github....Link is at end of post.

How to Run the Project

Make sure you have Python 3.x installed

Download or clone the repository:

git clone https://github.com/bilal-dev-0x/random-news-headline-generator.git
cd random-news-headline-generator
Enter fullscreen mode Exit fullscreen mode

Run the project:

python main.py
Enter fullscreen mode Exit fullscreen mode

Follow the on-screen instructions to generate random headlines πŸŽ‰

Why this project is useful

  • Even though it’s a small project, it helps you:
  • Practice Python loops and lists
  • Understand random module usage
  • Learn how to structure a small project
  • Build something fun and shareable

It’s a great starting point before moving on to GUI apps or web projects.

Next Steps / Improvements

  • Add more categories (Sports, Tech, etc.)
  • Add file export to save generated headlines
  • Convert it into a GUI app using Tkinter
  • Share it as a web app using Flask or Streamlit

Final Thoughts

This Random News Headline Generator is a fun beginner project that you can finish in a few hours.

It’s a good addition to your portfolio because it shows you can:

  • Work with Python basics
  • Build small projects
  • Think about user interaction

Check out the GitHub repo here:
Random News Headline Generator

Connect with me on LinkedIn:
Bilal Aslam

Top comments (0)