Académique Documents
Professionnel Documents
Culture Documents
They think, "oh no, I've done something wrong again" and "clearly
coding isn't for me, even the computer knows," but that's the wrong
way of thinking! Every programmer, even the most experienced ones,
encounter errors all the time. In fact, believe it or not, experienced
programmers likely encounter far more errors than a new
programmer ever will.
In fact, there are entire engineering roles built around finding and
fixing errors. A site reliability engineer finds and report errors in web
platforms. A test engineer builds automated tests to discover errors
in software and make sure that it meets a companies standards.
The following steps will guide you through a standard error that
might get thrown your way as you learn to code, and they'll show you
that errors aren't as scary as they seem. In fact, the steps are mostly
a combination of reading the error carefully or copy pasting it in a
Google search!
I ran into an error recently when I was trying to create a program that
could store a list of grades for a bunch of classes a fictional student
might be taking. I had a list of classes and a list of grades, and I
wanted to combine them into list of (class, grade) pairs that I
could add and remove classes and grades from.
That's our error message! This is what went wrong. We may not
know exactly what it means yet, but we're on the path to finding out!
We know that we used a zip object in our code, so that could be a
great place to start.
Copy and paste the important part of the error message into a search
engine and look through several pages if necessary until you find
someone else who has also run into that issue. Google is always a
good place to check, but another excellent resource to search through
is Stack Overflow, which is a wonderful community of programmers
sharing knowledge and building cool stuff.
Even if their code is wildly different, the one or two lines that threw
the error might be very similar to your code, so the solution may end
up being the same.
Hmm, I'm running Python 3, and all he had to do to fix his code was
change images = zip(bufferArray[:,0]) to
images = list(zip(bufferArray[:,0])) . It's worth a shot!
Thankfully, thortom 's solution was able to solve my issues with the
.zip() object. All I had to do was convert it into a list.
In the process of figuring out this compiler error, I learned that zip()
doesn't return a list, it returns an iterator. I also learned that this is a
new feature of Python 3 that didn't exist with Python 2.7. See, every
error is an opportunity to learn!
The solutions to your errors are out there, and the process of finding
them will make you a stronger and more confident programmer. As
you grow and learn, expect to encounter countless errors, and expect
each one to be its own unique learning opportunity.