IntermediateLesson 18 of 306 min read

Coding and formula help for non-coders

Use ChatGPT to explain code and formulas, fix error messages and create small scripts and web pages safely, even without coding experience.

In this lesson you will

  • Ask for plain-English explanations of code
  • Fix formulas and errors with exact messages
  • Generate and test small scripts safely
  • Spot risks before running code

About 17 minutes

You do not need to be a programmer to benefit

Imran has a folder with 300 product photos named IMG_0001 to IMG_0300 and needs them renamed with the product names. Hira has a spreadsheet formula that returns an error she cannot read. Mina wants a tiny web page for her shop’s opening hours. None of them is a programmer, and none needs to become one. Code is just another kind of writing, and ChatGPT is very good at it. This lesson shows non-coders how to use it for three things: understanding code and formulas, fixing errors, and generating small tools safely.

Good to know

If you are completely new to coding, our Python, HTML and JavaScript courses on this site teach the basics step by step. This lesson is about using the assistant as a helper, not about replacing learning.

1. Explain code in plain words

Found a script online or inherited a macro? Paste it and ask for a walk-through.

Explain this code line by line for a complete beginner. Then tell me in two sentences what the whole thing does, and whether anything in it could be dangerous to run.
[paste code]

The last question matters. Scripts can delete files, send data or install things. Before you run anything you do not understand, ask what it changes.

2. Explain and fix spreadsheet formulas

This Google Sheets formula returns #N/A: =VLOOKUP(A2, Prices!A:B, 2, FALSE). Explain what each part means and list the three most likely reasons for the error.
VLOOKUP looks for the value in A2 in the first column of Prices!A:B and returns the matching value from the second column. #N/A means no match was found. Likely reasons: 1) extra spaces or different spelling in either list, 2) numbers stored as text in one list, 3) the value really is missing from the Prices sheet. Try =TRIM(A2) and check both lists for hidden spaces.

3. Read and fix error messages

Error messages look scary, but they usually say exactly what is wrong. Paste the message and the code around it. Here is a tiny, real example. This script has a mistake. We ran it to capture the exact error Python produced:

numbers = [4, 8, 15, 16, 23, 42]
total = 0
for n in numbers
    total += n
print("Average:", total / len(numbers))
File "average.py", line 3
    for n in numbers
                    ^
SyntaxError: expected ':'
I ran this script and got the error below. Explain what it means in simple words, show the fixed code, and tell me what changed.
[paste code]
[paste error]

The fix is a missing colon at the end of the for line. After adding it, the script was run again:

numbers = [4, 8, 15, 16, 23, 42]
total = 0
for n in numbers:
    total += n
print("Average:", total / len(numbers))
Average: 18.0
Always include the full error

Copy the whole error message, not a paraphrase, and the lines of code around it. Details such as the line number and error type are exactly what the assistant needs.

4. Generate small tools

For small, well-defined jobs, such as renaming files, counting words, tidying a spreadsheet export or making a simple web page, ChatGPT can write a script. The key is a precise request.

Write a Python script that counts how many times each word appears in a piece of text, ignores common words like 'the' and 'and', and prints the top 3. Put the sample text inside the script so I can test it. Explain how to run it on Windows.

Here is a script of that kind. We ran it, so the output is real:

from collections import Counter
import re

text = """The shop sells candles. The candles are hand poured.
Customers love the lavender candles, and the shop ships fast."""

words = re.findall(r"[a-z']+", text.lower())
ignore = {"the", "and", "are", "a", "of", "to"}
counts = Counter(w for w in words if w not in ignore)

for word, n in counts.most_common(3):
    print(word, n)
candles 3
shop 2
sells 1

Notice the sample text is inside the script so you can test it. Always test a new script on a small, safe example first.

5. A safe workflow for AI-written code

  1. Describe the task precisely: inputs, outputs, your operating system.
  2. Ask for an explanation alongside the code.
  3. Read the code. Even if you do not understand all of it, look for anything that deletes, uploads, installs or reads private files.
  4. Test on a copy or a small sample, never on your only copy of important files.
  5. Run it and compare the result with what you expected.
  6. If it fails, paste the exact error back and iterate.
  7. Keep a backup before anything that changes many files.
Common mistake

Running code that deletes or moves files on your real folder first. Test on a copy. A tiny mistake in a rename script can scramble hundreds of files.

Common mistake

Copying code that uses someone’s secret key or password and then sharing the file. Keep secrets out of the code and out of chats.

6. Things it does well, and where it slips

Good at Be careful with
Short scripts and functions Large programs with many connected files
Explaining errors Very new tools and fast-changing libraries (it may use out-of-date commands)
Formulas and queries Security-sensitive code such as logins and payments
Converting between languages Subtle logic that needs real testing
Writing tests and comments Performance on huge data

7. A tiny web page

Write a single HTML file for a one-page website for a small bakery. Include the name, a short intro, opening hours as a list, a contact button that opens an email, and a clean modern style. Use plain HTML and CSS only, no external files.

Save the answer as index.html, double-click to open it in a browser, and ask for changes in plain English: “make the button green”, “add a photo section”. It is a great way to learn how pages work.

8. Learn from it

Teach me by asking questions. I want to understand how the script above works. Ask me what I think the next line does, wait for my answer, then correct me.

Used this way, the assistant becomes a coding tutor. After a few weeks of reading and tweaking its code, you will understand far more than you expect.

Security and privacy basics

  • Do not paste real passwords, API keys or customer databases into a chat.
  • Do not run code you cannot explain, especially from unknown websites.
  • Be suspicious of any script that asks you to disable security software or to download extra files.
  • Use official sources and package names. Look-alike names are a known trick.
  • For anything handling money or personal data, get a professional review.
A good habit

Keep a folder called “AI scripts” with each script, a note on what it does, the date, and what you tested. Future you will be grateful.

Check what you learned

Five quick questions. Pick an answer and you will see straight away whether it is right and why.

What is a smart question before running unknown code?

  1. What colour is it?
  2. Is it long?
  3. Who wrote the font?
  4. What does it change, and could it be dangerous?

Scripts can delete or send things.

What should you paste when asking about an error?

  1. A paraphrase only
  2. The full error message and the code around it
  3. Nothing
  4. Only the file name

Exact details help diagnose the problem.

Where should you first test a file-renaming script?

  1. On your only copy
  2. On a stranger’s computer
  3. Nowhere
  4. On a copy or small sample

Protect originals.

In the example, what caused the error?

  1. A missing colon after the for line
  2. A missing number
  3. A long list
  4. An extra space

Python needs a colon after for.

Which code needs a professional review?

  1. A wordcount script
  2. A greeting page
  3. Logins and payments
  4. A recipe list

Security-critical code is risky to copy blindly.

Summary

  • It explains, fixes and drafts code.
  • Give exact error messages and context.
  • Test on copies; read for anything that deletes or sends.
  • Use it to learn, not just to copy.

Next lesson

Next: image creation, getting reliable, on-brand pictures from words.

Questions

Do I need to know programming to use these tips?

No. Start with explanations and small, safe scripts. Learning the basics later will help you judge the output.

The code it gave me does not work. Why?

It may use an old command, a missing package or a different system than yours. Paste the exact error and your operating system and ask again.

Can I sell software written by ChatGPT?

Generally the terms allow it, but you are responsible for quality, security and licences of any libraries it uses. Test carefully.

Progress is saved in this browser.