Describe the expected vs actual output and paste your code. Get a root cause analysis with a fix you can apply immediately.
Copy the prompt, fill in what the code should do, what it actually does, and paste your code snippet.
I need help debugging this code. It is supposed to do [EXPECTED OUTPUT], but instead it produces [ACTUAL OUTPUT]. Please: 1. Identify the root cause of the bug 2. Explain step-by-step why the current code produces the wrong output 3. Provide the corrected code with comments explaining each change 4. List any other potential issues you notice 5. Suggest a test case that would have caught this bug Here is the code: [paste your code here]