Hello! If you've been sent a link to this page, by me or someone else, you've probably asked for some help with your Python program. I try to respond to as many emails as possible, but right now I have 455 unread emails. In the next section I explain why I'm so slow to reply (or often don't reply at all) but you can skip directly to instructions for how to ask programming questions.
Why I Didn't Reply To Your Email Yet (or Ever)
Emails asking for general career advice, or just to say thanks, or ask a very specific programming question are fairly easy to reply to. The emails that take the longest to reply are the ones that say, "Why doesn't my program doesn't work?"
I reply to some of these emails, but often I literally can't answer them; either I don't have enough information about your problem
If I sent you a link to this blog post, you probably sent me a "my program doesn't work" email. Please don't take offense! I thought it would be more helpful to me (and you!) to know how to ask programming questions effectively. There is a term that experienced programmers would often slap folks with questions: RTFM, which stands for "read the fucking manual". I hate this acronym; it's condescending and arrogant. The more modern, but still rude, acronym is LMGTFY, or "let me google that for you". But these phrases exist because often the questions are simple enough to be answered by searching the web.
By my estimates, between my books, videos, and online courses (most of which are freely available online) about 20,000 people have learned how to program somewhat proficiently because of the work I do. This is great! I assume the overwhelming amount of people who download or buy my work don't finish it. (I've signed up for over a dozen online courses, I've only finished two.) I'm amazed that the internet lets me cheaply share knowledge. I can reach more people in a few years online than a lifetime at the front of a classroom.
When I get a "why doesn't my program work?" email, I can only help one person at a time. On top of this, when I receive short questions that require long answers, that means I have to do a lot of work, for free, to help one person who didn't seem to spend much effort trying to research the question themselves.
I don't want to discourage people from asking questions, but there's a few steps you can take to ask programming questions effectively.
It's not hard to answer the question, "Why doesn't my program work?". But it's almost impossible to answer that question when it is the only thing that is asked. Run through this check list before clicking Send:
Before you email, consider posting the problem to the /r/inventwithpython subreddit or StackOverflow.
The /r/inventwithpython subreddit will probably answer your questions about code in my books faster than I can reply to your email.
To make itself as useful to as many people as possible, StackOverflow carefully moderates questions posted to its site. You must read the short How do I ask a good question? page first. This page is also good to read for asking for programming help in general.
Before you email, google your question. If you got an error message, copy and paste the error into google.
You are never the first person to encounter this error, and someone else has probably answered your questions already. In this case, you'll get an answer much faster by searching the web for it.
Before you email, learn to use a debugger, and use a debugger.
A debugger lets you run through your code one step at a time, and examine what values are in your variables. IDLE comes with a debugger, and you can also always use the pdb debugger module. A debugger saves you much more time than it takes to learn how to use a debugger.
Before you email, run your code through PythonTutor.com.
PythonTutor.com will run your program and create a step-by-step visualization for how it works. There are several limitations: the program cannot run for too long, can't read or write files, and must stick to the Python Standard Library of modules. But for short programs PythonTutor.com works even better than a debugger.
In your email, show me that you've done research.
Add something like, "I googled for (terms) and found a StackOverflow post at (url), but I don't understand what this person means when they say (something)."
In your email, don't ask to ask. Just ask.
You don't have to say "I have a question about (something). Can you help me with this?" It isn't considered rude amongst programmers to just ask me the question, provided you are following the guidelines in this article. My answer to "Can I ask you a question?" is always "Yes", but it might take me a few days to reply, and then another few days to reply to your actual question.
If you are asking your question somewhere online, think of the search engines and people in the future who might read your post. Choose a post headline that describes your problem. A headline of "I have a question about Python" isn't helpful for someone looking through search engine results. (This advice also applies to email subject lines.) It's considered rude to have a vague, demanding headline like, "HELP!!! My program keeps CRASHING. WHY DOESN'T ANYONE ANSWER ME?!?!?!1"
In your email, don't just tell me what your program is doing, but also tell me the overall goal of your program.
I often get somewhat weird questions that make think, "why are you trying to write this particular code?" I might be able to put you on a new, simpler path to solve your problem.
In your email, copy and paste the full error message.
Python error messages will look something like this:
Traceback (most recent call last): File "test1.py", line 18, in <module> spam() File "test1.py", line 16, in spam bar() File "test1.py", line 13, in bar foo() File "test1.py", line 4, in foo int(x) ValueError: invalid literal for int() with base 10: 'twelve'
In order to help you, I need all of this information. If you just tell me "I got a ValueError" or "I got an error", I simply don't know enough to tell you what's wrong.
In your email, send me a pastebin link to the full source code of your program.
Without the complete, full source code, I don't have enough information to help you. Go to a "pastebin" site like https://pastebin.com/ or https://gist.github.com/. This way, I can run your program myself.
Do not copy and paste the code into the email itself. Blank lines at the top of the code will throw off the line numbers in the error message, and many email programs will get rid of the indentation, which renders the code unrunnable.
Do not send me a screenshot of the code. I can't copy and paste the code in the image, so I can't run the program. Twice people took smartphone photos of their laptop screen and sent that to me. They get points for ingenuity, but I can't copy and paste code from that either.
In your email, say what operating system, operating system version, and version of Python you are using.
There are minor but possibly important differences between operating systems and Python versions. Telling me, "I'm running Python 3.6.2 on Windows 10" helps me narrow down what could be causing your problem.
In your email, if you have a question about something in one of my books, tell me which book, chapter, and page number you were reading.
I've written several books, so I might not know what you're talking about if you tell me "my book". Please tell me which book, but also the chapter and (possibly) the page number. The page number is precise, but if I don't have the book or PDF nearby, I'll read my book online and I'll only have the chapters instead of the page numbers.
Going through this checklist makes it much more likely that you'll get a quick answer. Providing more information helps me help you. And posting to an online forum like the /r/inventwithpython subreddit allows many people to answer your question while creating a page that people in the future with a similar problem can find.
Good luck, and keep coding!
A common question I get from readers is "what should I study/read/learn next?" If you've read Automate the Boring Stuff with Python, you might want to read my other books for free online. I also recommend Python Crash Course (you can skip directly to the second half if you're comfortable with Python) and Fluent Python and Effective Python. If you want practice writing simple programs, try the practice problems on Exercism.io or the /r/dailyprogrammer subreddit.