> code & data
For coding and data work, ChatGPT is fastest when you hand it the real inputs — the actual error, the real schema, the exact function — instead of paraphrasing. It drafts functions, tests, queries, and formulas, but treats none of it as verified: run the code, read the query, check the formula's dialect.
// code & data
6 entries> # Write a Python function that: # 1. asks the user for a distance in miles # 2. converts miles to kilometers # 3. prints the result rounded to 2 decimals import> This function throws the error below. Explain the root cause, then give the corrected code. Code: [paste code] Error: [paste traceback]> Write pytest tests for the function below. Cover normal cases, empty and boundary inputs, and invalid types. Add a one-line comment on what each test verifies. Function: [paste function]> Extract the details below into JSON with keys name (string), email (string), company (string), and signup_date (YYYY-MM-DD). Use null for anything not present. Return only the JSON. Text: [paste text]> Given these tables, write a PostgreSQL query for the request. Schema: [paste CREATE TABLE statements] Request: total revenue per customer for orders placed in 2025, highest first.> Write an Excel formula that sums column C where column A equals "Paid" and column B is after 2025-01-01. Explain each argument.// faq
Why does ChatGPT invent functions or columns that don't exist?
It is pattern-matching to what usually exists, not to your specific setup. Paste the real schema, library versions, or API so it uses your actual names. Then run or test the output — generated code and SQL should never go to production unchecked.
How do I get better help debugging?
Paste the failing code, the full error or traceback verbatim, and what you expected. The error text names the file, line, and exception, which is the highest-signal input. Ask for the root cause plus the fix, not just a patched snippet.
Can ChatGPT write spreadsheet formulas?
Yes. Describe the calculation and the cell ranges and name the app — Excel and Google Sheets differ in function names and argument separators. It handles XLOOKUP, SUMIFS, and INDEX/MATCH, and explains each argument so you can adapt it.
Is it safe to use ChatGPT-generated tests?
Review them. Generated tests sometimes assert the code's current behavior — bugs included — rather than the correct behavior. Check each assertion against what the function should do, and add domain-specific edge cases the model cannot know about.