29 common beginner Python errors on one page

A few times a year, I have the job of teaching a bunch of people who have never written code before how to program from scratch. The nature of programming being what it is, the same error crop up every time in a very predictable pattern. I usually encourage my students to go through a step-by-step troubleshooting process when trying to fix misbehaving code, in which we go through these common errors one by one and see if they could be causing the problem.  Today, I decided to finally write this troubleshooting process down and turn it into a flowchart in non-threatening colours.

Behold, the “my code isn’t working” step-by-step troubleshooting guide! Follow the arrows to find the likely cause of your problem – if the first thing you reach doesn’t work, then back up and try again.

Click the image for full-size, and click here for a printable PDF. Colour scheme from Luna Rosa.

Update: hi, Reddit!

Update 2: a couple of viewers have correctly pointed out that one of the examples – using a single equals sign in an if statement – actually generates a SyntaxError in Python. Oops! That example was left over in my brain from my days of teaching Perl! I’ve updated the flowchart and replaced that example with another common error which is dear to my heart – comparing an int with a string representation of an int (for example, read from an input file).

Also available in a Russian translation.

Also available in Brazilian Portuguese.


19 Responses to 29 common beginner Python errors on one page

  1. Damian Cugley August 6, 2013 at 10:04 am #

    Not just for beginners—these are the most common mistakes I make in my code as well… 🙂

  2. Juanlu August 7, 2013 at 7:10 pm #

    This is great! Do you have a localizable version? =)

    • martin August 8, 2013 at 1:08 pm #

      No, but if you want to make a modified version for any reason, drop me an email and I’ll send you the SVG.

  3. Andy August 7, 2013 at 10:12 pm #

    That looks great. Which tool did you use to create it?

  4. James August 8, 2013 at 3:36 pm #

    I am unable to view the PDF. Is the link broken?

    • martin August 12, 2013 at 4:50 pm #

      Don’t think so, it is working OK for me.

  5. pirateboxge August 15, 2013 at 10:04 am #

    Great works !!!
    Is it possible to have the source files for a french traduction ?

    Thanks.

    • martin August 15, 2013 at 3:38 pm #

      Sure, drop me an email: martin@pythonforbiologists

  6. isomorphismes August 22, 2013 at 9:44 pm #

    Thank you. Most people who know what they’re doing wouldn’t put in this amount of effort toward helping the newbies. Hopefully the people who need to see this find out it’s here.

  7. Jess Hamrick August 27, 2013 at 8:16 pm #

    This is great, thanks! I am definitely going to point people to this in the future. Also, if you ever do another version and have the room, I would suggest adding IndexError — I’ve seen a lot of beginners get them who are confused about zero-indexing and try to retrieve the nth element of a list using n rather than n-1 or just -1.

    • martin August 28, 2013 at 6:49 am #

      Good idea. Maybe I will start collecting material for a second page of common errors!

  8. Alconost July 24, 2015 at 3:03 pm #

    Great article, thank you!

    We translated this post and pic into Russian: http://habrahabr.ru/company/alconost/blog/263403/

  9. Crys Smith November 14, 2015 at 3:54 pm #

    This poster is great. Thank you for sharing it.

Trackbacks/Pingbacks

  1. 29 common beginner Python errors on one page | ... - August 6, 2013

    […]   […]

  2. 开发资讯热点回顾 2013-08-07 - 博客 - 伯乐在线 - August 8, 2013

    […] 《信息图:Python新手常见的29个错误》新手学编程时总会遇到一些相同错误,在鼓励学生努力一步一步解决问题,Martin 根据学生遇到的问题,制作了一张定位问题的流程图。http://t.cn/zQCYRQn […]

  3. 29 common beginner Python errors on one page | Python for biologists | Computer Science Education Resources - August 9, 2013

    […] via 29 common beginner Python errors on one page | Python for biologists. […]

  4. Visto nel Web – 91 | Ok, panico - August 11, 2013

    […] 29 common beginner Python errors on one page ::: Python for biologists […]

  5. 29 common beginner Python errors on one page. | Gordon's shares - September 5, 2013

    […] Link. I’ll add it to my learning python blog post. […]

Leave a Reply

Powered by WordPress. Designed by Woo Themes