代码调试与错误修复提示
来自 Wikiprompt,自由的提示词百科全书
代码调试与错误修复提示 要求AI调试一个在空列表上出错的Python函数,并需要解释根本原因及提供修复方案的提示。
提示词内容收藏
🌐
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
用法
此提示词专为 coding 设计。复制上方内容并粘贴到你常用的 AI 工具中。
为获得最佳效果,可将占位符(方括号或大写字母标示)替换为你的具体需求。
讨论
0 条评论