- Sloth Bytes
- Posts
- 🦥 How To Ask Better Programming Questions
🦥 How To Ask Better Programming Questions
Hello friends!
Welcome to this week’s Sloth Bytes (late edition).
There’s a reason 400,000 professionals read this daily.
Join The AI Report, trusted by 400,000+ professionals at Google, Microsoft, and OpenAI. Get daily insights, tools, and strategies to master practical AI skills that drive results.
Baby sloths are born with everything
Baby sloths are born with their eyes open, their claws sharp, and their teeth fully formed. They don’t really have a development period.
The Art of Asking Better Programming Questions
One day you’ll have to ask a question about programming, and when that day happens you’re going to waste time because you don’t know how to ask it.
Let me save you the embarrassment and help you create better questions.
You can also use these when asking AI questions.
The XY Problem: What Not To Do
❌ "How do I detect if a user has stopped typing?"
✅ "I'm implementing a search that should only call the API when the user finishes typing. This is my current code: "
Always explain your end goal - you might be solving the wrong problem!
The Perfect Question Formula
Context First
❌"My code isn't working. Help!"
✅"I'm building a Python web scraper that needs to handle pagination. Currently using BeautifulSoup. The first page works, but it breaks on page 2. Here's my code: … "
Show Your Work
❌"I can't get my sorting to work. What's the best way to sort?"
✅ "I'm trying to sort a list of dates, here’s what I’ve tried:
dates = ['2024-01-01', '2023-12-31']
sorted_dates = sorted(dates)
It’s not working as expected:
#Expected
['2023-12-31', '2024-01-01']
#Actual
['2024-01-01', '2023-12-31']
Include Error Messages
❌ "I'm getting some weird error about None or null or something"
✅ I’m getting the following error
TypeError: 'NoneType' object is not subscriptable at line 23: data['users']
Where to Ask Questions
Stack Overflow
Tag properly
Use code formatting
Include minimal reproducible example
GitHub Issues
Search closed issues first
Follow issue templates
Include package versions
Discord/Slack
Use code blocks
Right channel/thread
Be patient
ChatGPT of course
Question Checklist
Did you search for existing answers?
Did you Include environment details?
Did you Add relevant code?
Did you described expected vs actual?
Did you format properly?
Did you proofread for clarity?
Red Flags in Your Question
❌ "Can anyone help?"
❌ "URGENT!!!"
❌ "It's not working"
❌ "Here's 300 lines of code"
❌ "Fix this for me"
Writing Good Question Titles
❌ "JavaScript help needed"
❌ "URGENT: Code not working!!!"
✅ "TypeError when accessing nested JSON in Express middleware"
Real-World Examples
Before:
Help! Code not working! var x = [1,2,3] need to make bigger
After:
I need to append elements to array in JavaScript I have an array:
const x = [1,2,3]
// I tried
x.add(4)
//But I keep getting this error
// x.add is not a function
//Expected output: x should now be [1,2,3,4]
Environment: JavaScript (Node v16)
Additional tips
Screenshot errors if they're visual
Recreate the error
Update your question with solutions you've tried
Answer your own question if you solve it!
Remember
Every great developer started as a beginner
Clear questions save everyone's time
Good questions build your reputation
Teaching others reinforces your knowledge
Writer RAG tool: build production-ready RAG apps in minutes
RAG in just a few lines of code? We’ve launched a predefined RAG tool on our developer platform, making it easy to bring your data into a Knowledge Graph and interact with it with AI. With a single API call, writer LLMs will intelligently call the RAG tool to chat with your data.
Integrated into Writer’s full-stack platform, it eliminates the need for complex vendor RAG setups, making it quick to build scalable, highly accurate AI workflows just by passing a graph ID of your data as a parameter to your RAG tool.
*A message from our sponsor.
Thank you to everyone who submitted 😃
RelyingEarth87, Viidka, JamesHarryT, pyGuy152, sonvalle, agentNinjaK, dropbearII, ravener, GiantMango, pavan-15-hub, and last one:
Invert Colors
Create a function that inverts the rgb
values of a given list
Examples
color_invert([255, 255, 255])
output = [0, 0, 0]
# [255, 255, 255] is the color white.
# The opposite is [0, 0, 0], which is black.
color_invert([0, 0, 0])
output = [255, 255, 255]
color_invert([165, 170, 221]
output = [90, 85, 34]
Notes
Must return a list.
255 is the max value of a single color channel.
How To Submit Answers
Reply with
A link to your solution (github, twitter, personal blog, portfolio, replit, etc)
or if you’re on the web version leave a comment!
That’s all from me!
Have a great week, be safe, make good choices, and have fun coding.
If I made a mistake or you have any questions, feel free to comment below or reply to the email!
See you all next week.
Reply