Ai Coding Tools

How to Use GitHub Copilot to Write Python Code in 30 Minutes

By BTW Team3 min read

Comparing tools? See the AI tools tested on the show.

In short

A step-by-step guide on leveraging GitHub Copilot effectively to write a fully functional Python application in just half an hour.

If you’re a solo founder or indie hacker, you know that time is your most precious resource. Writing code can be a bottleneck, especially when you’re juggling multiple projects. Enter GitHub Copilot: an AI-powered coding assistant that can help you write Python code faster. In this guide, I’ll show you how to get started with GitHub Copilot in just 30 minutes.

Prerequisites

Before we dive in, make sure you have the following:

  • A GitHub account (free tier is sufficient)
  • Visual Studio Code (VS Code) installed
  • The GitHub Copilot extension installed (requires a subscription)

Time Estimate: 30 minutes

This setup and coding session should take you about 30 minutes if you follow along step by step.

Step 1: Setting Up GitHub Copilot

  1. Create a GitHub Account: If you don’t already have one, sign up at GitHub.
  2. Install Visual Studio Code: Download and install VS Code from here.
  3. Install GitHub Copilot: Open VS Code, go to Extensions (Ctrl+Shift+X), and search for "GitHub Copilot". Click "Install".
  4. Subscribe to GitHub Copilot: As of July 2026, GitHub Copilot costs $10/month after a free trial.

Expected Output

After this step, you should have a fully functional GitHub Copilot ready to assist you in writing Python code.

Step 2: Writing Your First Python Function

Let’s create a simple Python function to calculate the factorial of a number.

  1. Open a New File: In VS Code, create a new file called factorial.py.
  2. Start Typing: Begin typing the function definition:
    def factorial(n):
    
  3. Invoke Copilot: After typing the function signature, press Tab to see Copilot’s suggestions. It should suggest a complete implementation for calculating the factorial.

Expected Output

You’ll end up with a working function that looks something like this:

def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)

Step 3: Testing the Function

Now that you have your function, let’s test it.

  1. Add Test Cases: Below your function, add some test cases:
    print(factorial(5))  # Should return 120
    print(factorial(0))  # Should return 1
    
  2. Run the Code: Use the terminal in VS Code to run the file:
    python factorial.py
    

Expected Output

You should see:

120
1

Troubleshooting Common Issues

  1. Copilot Doesn’t Suggest Code: Make sure you are logged into GitHub in VS Code and that the Copilot extension is enabled.
  2. Function Doesn’t Work: Double-check your syntax and ensure you’re testing with valid inputs.

What’s Next?

Now that you’ve written a simple Python function using GitHub Copilot, consider expanding your project. Here are a few ideas:

  • Build a small CLI application that utilizes multiple functions.
  • Explore more complex algorithms, like sorting or searching algorithms.
  • Integrate your code with an API to fetch and manipulate data.

Conclusion

If you’re looking to speed up your coding process, GitHub Copilot is a powerful tool that can save you time and effort. In just 30 minutes, you’ve set up Copilot and written your first Python function.

Start Here

To maximize your productivity, consider subscribing to GitHub Copilot and integrating it into your daily workflow. It’s a worthwhile investment for indie hackers and solo founders looking to ship faster.

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools
Ai Coding Tools

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them)

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them) In the everevolving landscape of AI coding tools, it's easy to get swept up in the hype. As indie hackers and s

Nov 30, 20263 min read
Ai Coding Tools

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026 In 2026, the landscape for indie hackers and solo founders has evolved significantly, especially with the advent

Nov 26, 20264 min read
Ai Coding Tools

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026 If you’re a developer stuck maintaining legacy code, you know the frustration. It’s like navigating a maze blindfolde

Nov 23, 20264 min read
Ai Coding Tools

10 AI Coding Tools That Will Save You Hours of Debugging in 2026

10 AI Coding Tools That Will Save You Hours of Debugging in 2026 Debugging can feel like a neverending cycle of frustration. Whether you're a solo founder or an indie hacker, spend

Nov 18, 20265 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for MVP Development

10 Common Mistakes When Using AI Coding Tools for MVP Development As a founder in 2026, you’re likely aware that AI coding tools can significantly speed up the MVP development proc

Nov 16, 20264 min read
Ai Coding Tools

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026 As a beginner developer, you’ve probably come across a ton of buzz surrounding AI coding tools. But with all the hyp

Nov 12, 20263 min read