Ai Coding Tools

How to Write Python Code Using GitHub Copilot 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 to quickly set up and start writing Python code with GitHub Copilot in just 30 minutes.

If you've ever stared at a blank screen, grappling with how to start writing Python code, you're not alone. As indie hackers and solo founders, we often find ourselves juggling multiple roles, and coding should be as efficient as possible. Enter GitHub Copilot, an AI-powered coding assistant that can help you write Python code faster and with fewer headaches. In this guide, I’ll walk you through how to leverage Copilot effectively in just 30 minutes.

Prerequisites: What You Need

Before diving in, here’s what you need to get started:

  • GitHub Account: You’ll need to sign up for GitHub (free).
  • Visual Studio Code (VS Code): Download and install VS Code.
  • GitHub Copilot Subscription: Copilot costs $10/month after a free trial. You'll need to set this up in your GitHub account.
  • Basic Python Knowledge: Familiarity with Python syntax and concepts will help, but Copilot can assist even if you're a beginner.

Step 1: Setting Up GitHub Copilot

  1. Install the GitHub Copilot Extension:

    • Open VS Code.
    • Go to the Extensions view (Ctrl + Shift + X).
    • Search for “GitHub Copilot” and click “Install”.
  2. Sign In:

    • After installation, you’ll be prompted to sign in to your GitHub account.
    • Follow the instructions to authorize Copilot.
  3. Configure Settings:

    • Navigate to settings (File > Preferences > Settings).
    • Search for “Copilot” and adjust preferences as needed, such as enabling inline suggestions.

Step 2: Writing Your First Python Function

Example Task: Create a Simple Calculator

  1. Open a New Python File:

    • Create a new file called calculator.py.
  2. Start Coding:

    • Type a comment describing the function you want to create. For example:
      # Create a function to add two numbers
      
    • Wait a moment for Copilot to suggest code. You should see a suggestion pop up.
  3. Accept Suggestions:

    • If the suggestion looks good, press Tab to accept it. If not, you can cycle through suggestions using Ctrl + ] or Ctrl + [.
  4. Test the Function:

    • After writing your function, add a test case:
      print(add(5, 3))  # Expected output: 8
      

Expected Output:

When you run the file using python calculator.py, you should see the output:

8

Step 3: Iterating on Your Code

After your initial function, you might want to expand your calculator. Simply describe what you want in comments, and Copilot will provide suggestions. For example, to create a subtraction function, type:

# Create a function to subtract two numbers

Then accept the suggestion and test it similarly.

Troubleshooting: What Could Go Wrong

  • No Suggestions Appearing: Ensure you’re connected to the internet and logged into GitHub. Restarting VS Code can sometimes resolve this.
  • Irrelevant Suggestions: Copilot learns from context, so provide clear comments and structure in your code to improve suggestions.

What's Next: Building a Full Application

Once you’re comfortable with writing functions, consider building a more complex application. Perhaps a command-line interface (CLI) for your calculator or even integrating it with a web framework like Flask. Copilot can assist with these tasks as well.

Conclusion: Start Here

Using GitHub Copilot can significantly speed up your coding process, especially for indie hackers and solo founders. With just a bit of setup and some basic Python knowledge, you can harness the power of AI to write code faster and more efficiently.

What We Actually Use

In our experience, GitHub Copilot is essential for speeding up repetitive coding tasks. While it’s not perfect and occasionally makes odd suggestions, it’s a tool that has saved us countless hours.

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