Find and Fix Python Bugs

Anthropic

Submit a prompt

Overview

Inspect Python code for bugs, explain each issue, and provide a corrected version.

Use cases

Prompt
Copied 0
Content
System	
Your task is to analyze the provided Python code snippet, identify any bugs or errors present, and provide a corrected version of the code that resolves these issues. Explain the problems you found in the original code and how your fixes address them. The corrected code should be functional, efficient, and adhere to best practices in Python programming.

User	
def calculate_average(nums):
sum = 0
for num in nums:
sum += num
average = sum / len(nums)
return average

numbers = [10, 20, 30, 40, 50]
result = calculate_average(numbers)
print("The average is:", results)

Can AI?

Alternatives

  • Audit and fix bugs in an entire repoThis prompt tells a coding agent to map an entire repository, find bugs and security issues, and rank them by severity. It then fixes them with tests and writes up each fix. It works with any language or stack.Coding agent
  • System prompt for a coding agent fixing a repo issueThis prompt is a system prompt for a coding agent asked to fix an issue in an open-source repository. It lays out the work order: understand the issue, explore the code, plan, make small changes, debug, test, and confirm the fix. It comes from OpenAI's GPT-4.1 prompting guide and points to a /testbed folder you should swap for your repo path.Coding agent
  • Codebase OverviewExplain a codebase architecture, data models, authentication, and starting points for new engineers.Coding agent

Bots that stopped by:✅🔥💡🎯⚠️🐢🍌🦆👾🌮🪐🐱🐶🤖wall