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 like me, you often find yourself staring at a blank screen, waiting for inspiration to strike. Writing Python code can sometimes feel like pulling teeth, especially when you're not entirely sure how to approach a problem. Enter GitHub Copilot, a tool that can help you generate code snippets in real-time, making your coding experience smoother and faster. In this guide, I'll show you how to leverage GitHub Copilot to write Python code in just 30 minutes.

Prerequisites

Before diving in, make sure you have the following:

  1. GitHub Account: You'll need an account to access GitHub Copilot.
  2. Visual Studio Code (VS Code): This is the IDE where you'll be using Copilot.
  3. GitHub Copilot Subscription: As of June 2026, GitHub Copilot costs $10/month for individuals. There’s a free trial available for new users.
  4. Basic Python Knowledge: Familiarity with Python syntax will help you understand and refine the code Copilot suggests.

Step 1: Setting Up GitHub Copilot

  1. Install Visual Studio Code: Download and install VS Code.
  2. Install GitHub Copilot Extension:
    • Open VS Code.
    • Go to the Extensions tab (Ctrl+Shift+X).
    • Search for "GitHub Copilot" and click 'Install'.
  3. Sign In to GitHub: After installation, sign in using your GitHub credentials to activate Copilot.

Expected output: You should see a Copilot icon in the bottom right corner of VS Code indicating it's ready to help.

Step 2: Writing Your First Python Function

Let's write a simple function together—say, a function that calculates the factorial of a number.

  1. Create a New Python File: In VS Code, create a new file named factorial.py.
  2. Start Typing a Function Definition:
    def factorial(n):
    
  3. Let Copilot Suggest Code: After you press Enter, Copilot will automatically suggest code. You’ll see a greyed-out suggestion.
  4. Accept the Suggestion: If it looks good, hit Tab to accept. If not, you can keep typing or modify what Copilot suggests.

Expected output: You should see a complete factorial function. Here’s what it might look like:

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

Step 3: Testing Your Function

Now, let’s test the function to ensure it works correctly.

  1. Add Test Cases:
    print(factorial(5))  # Expected output: 120
    print(factorial(0))  # Expected output: 1
    
  2. Run the Code: Save your file and run it in the terminal:
    python factorial.py
    

Expected output:

120
1

What Could Go Wrong

  1. Copilot’s Suggestions Aren't Perfect: Sometimes, the code might not be what you expect. It’s crucial to review and understand every line.
  2. Syntax Errors: If you get a syntax error, double-check Copilot's suggestions and your own edits.
  3. Function Logic Errors: Ensure that the logic makes sense for your use case.

What's Next

Once you’re comfortable with writing functions, explore more complex Python tasks like:

  • Building a web scraper using libraries like Beautiful Soup.
  • Creating a simple API with Flask.
  • Analyzing data with Pandas.

Conclusion

In just 30 minutes, you can use GitHub Copilot to help you write Python code efficiently. While Copilot can boost your productivity, remember to critically evaluate its suggestions. You can start here by following the steps outlined above, and soon, you’ll be coding like a pro with a little help from AI.

What We Actually Use

For our projects, we rely heavily on GitHub Copilot for quick code generation, especially when tackling new libraries or APIs. However, we also make it a point to double-check every suggestion it provides.

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

How to Build and Deploy a Simple App Using AI Tools in Just 2 Hours

How to Build and Deploy a Simple App Using AI Tools in Just 2 Hours Ever felt overwhelmed at the thought of building and deploying an app? You're not alone. Many indie hackers and

Jun 20, 20264 min read
Ai Coding Tools

7 AI Coding Tools That Will Transform Your Development Process in 2026

7 AI Coding Tools That Will Transform Your Development Process in 2026 As a solo founder or indie hacker, the struggle to balance coding with all the other demands of your project

Jun 20, 20265 min read
Ai Coding Tools

The $100 AI Coding Toolkit for Indie Developers 2026

The $100 AI Coding Toolkit for Indie Developers 2026 As an indie developer, finding the right tools that fit your budget can be a challenge, especially when you're trying to levera

Jun 20, 20264 min read
Ai Coding Tools

How to Set Up AI Coding Assistants in 30 Minutes or Less

How to Set Up AI Coding Assistants in 30 Minutes or Less In 2026, the landscape of coding has dramatically shifted. As indie hackers and solo founders, we’re all looking for ways t

Jun 20, 20264 min read
Ai Coding Tools

Top 5 Mistakes First-Time Users Make with AI Coding Tools

Top 5 Mistakes FirstTime Users Make with AI Coding Tools As a firsttime user diving into AI coding tools, it's easy to get swept up in the excitement of automating your coding proc

Jun 20, 20264 min read
Ai Coding Tools

Bolt.new vs Codeium: Which AI Coding Tool is Better for Indie Hackers?

Bolt.new vs Codeium: Which AI Coding Tool is Better for Indie Hackers? As an indie hacker, you're probably juggling multiple roles—developer, marketer, and sometimes even customer

Jun 20, 20263 min read