Ai Coding Tools

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

By BTW Team3 min read

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

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.

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026 As AI coding tools have become an integral part of a developer's toolkit in 2026, many are still stumbling over

Oct 12, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026 As we dive into 2026, the landscape of AI coding tools has evolved significantly, yet many developers still

Oct 11, 20263 min read
Ai Coding Tools

Why AI Coding Assistants Are Overrated for Beginners in 2026

Why AI Coding Assistants Are Overrated for Beginners in 2026 As a solo founder or indie hacker, it’s tempting to think that AI coding assistants are the silver bullet to jumpstart

Oct 10, 20263 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for Beginners

10 Common Mistakes When Using AI Coding Tools for Beginners As a beginner in coding, diving into AI coding tools can feel like a doubleedged sword. On one hand, these tools promise

Oct 8, 20264 min read
Ai Coding Tools

5 Common Misconceptions About AI Coding Tools and Why They Hold You Back

5 Common Misconceptions About AI Coding Tools and Why They Hold You Back As a solo founder or indie hacker, you might be considering leveraging AI coding tools to boost your produc

Oct 7, 20264 min read
Ai Coding Tools

5 Common Misconceptions About AI Coding Tools That Will Hurt Your Learning

5 Common Misconceptions About AI Coding Tools That Will Hurt Your Learning As a beginner in coding, diving into the world of AI coding tools can feel like stepping into a futuristi

Oct 6, 20263 min read