Talk

Code Debugging & Error Fixing Prompt

From Wikiprompt, the free prompt encyclopedia

Alex Prompter
Contributed byAlex PrompterXSource

Feb 23, 2025

Code Debugging & Error Fixing Prompt A prompt asking an AI to debug a Python function that fails on empty lists, requiring root cause explanation and fix.

Prompt ContentSave

🌐
The following Python script has a bug causing incorrect output. Identify and fix the issue while explaining the root cause. The code: def calculate_average(numbers): total = sum(numbers) return total / len(numbers) # Error occurs when numbers is an empty list print(calculate_average([])) # Should handle edge cases properly

Sign in to see the full prompt

Continue with:

By logging in, you agree to our Terms of Use and Privacy Policy

Usage

This prompt is designed for use with coding. Copy the prompt content above and paste it into your preferred AI tool.

For best results, you may customize the placeholders (indicated by square brackets or capital letters) with your specific requirements.

References

Categories:coding| twitter| python| debugging

Talk