Ai Coding Tools

How to Write a Function Using Cursor in 30 Minutes

By BTW Team3 min read

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

In short

A step-by-step tutorial for beginners on how to quickly utilize Cursor for writing a simple function, aimed at speeding up coding tasks.

If you're new to coding or just starting to explore AI coding tools, you might find yourself overwhelmed by the plethora of options available. Cursor is one such tool that's gained traction among developers for its streamlined approach to writing code. In this guide, I’ll show you how to write a function using Cursor in just 30 minutes.

Prerequisites

Before diving in, make sure you have:

  • A Cursor account (free tier available)
  • Basic understanding of programming concepts (variables, functions)
  • Access to a computer with internet

Step-by-Step Guide

Step 1: Setting Up Cursor

  1. Sign Up: Go to Cursor's website and create a free account.
  2. Install Cursor: Download and install the Cursor application on your machine. It’s compatible with both Windows and macOS.
  3. Open the Application: Launch Cursor and create a new project.

Step 2: Familiarizing with the Interface

  • Code Editor: This is where you'll write your function.
  • AI Assistant: Cursor has an AI assistant that can help you with syntax and suggestions.

Step 3: Writing Your First Function

  1. Define Your Function: Start by typing the function definition. For example:
    def greet(name):
        return f"Hello, {name}!"
    
  2. Use the AI Assistant: If you’re unsure about the syntax, ask the AI assistant for help by typing “How do I define a function in Python?”
  3. Test Your Function: Call your function with a test input:
    print(greet("World"))
    
    Expected output: Hello, World!

Step 4: Debugging

  • If your function doesn’t work as expected:
    • Check for common errors like indentation or syntax mistakes.
    • Use the AI assistant’s debugging feature by selecting the problematic line and asking for suggestions.

Step 5: Save and Share

  • Once your function works, make sure to save your project. You can also share it with others directly from the Cursor interface.

Troubleshooting Common Issues

  • Function Not Returning Value: Ensure you have a return statement in your function.
  • Syntax Errors: Double-check your code for typos and proper syntax.
  • Cursor Not Responding: Restart the application if the AI assistant isn’t functioning properly.

What's Next?

Now that you've written a simple function, consider exploring more complex functionalities like:

  • Writing multiple functions
  • Working with data structures (lists, dictionaries)
  • Integrating Cursor with other tools for more advanced coding tasks

Conclusion

If you follow these steps, you can write a function using Cursor in just about 30 minutes. It’s a powerful tool that can help streamline your coding process, especially if you’re just starting.

Start here: Create your Cursor account and try writing your first function today!

What We Actually Use

In our team, we primarily use Cursor for quick prototypes and to leverage its AI capabilities for debugging and syntax suggestions. It's a great tool for indie hackers and solo founders who want to build efficiently without getting bogged down by syntax errors.

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