Practice Python by fixing errors

You can now practice Python by fixing errors. We have created a GitHub repository with common errors that Python beginners are likely to make in their code. This is not meant for intermediate level of Python developers. The errors are super basic and laughably simple for intermediate users. We created only simple challenges so that beginners can develop the momentum of small wins that comes from solving problems in an unknown space.
 


Background

Nobody writes perfect code. Nobody tests perfectly. Errors are a fundamental part of work. People proficient at something have not learned how to avoid errors. Instead, they have learned to read the error message, learned to figure out how to debug and fix the errors. Like all skills, dealing calmly with errors develops over time. However, beginners often feel demotivated when they hit a series of errors. So we thought we would control the kind errors that a beginner would see and help them retrain and rethink their initial response to errors.
 

Some side benefits of solving the errors in our repository include getting better at git, debugging, reading errors, Googling, etc.


Quick start

If you are already comfortable with git and GitHub, just proceed to our repo and follow the readme. Link: https://github.com/qxf2/wtfiswronghere
 


Detailed example

If you are very new to Python, and somewhat unfamiliar with git, you can follow these steps to fix 01_challenge. We assume you have a GitHub account. If not, please sign up for one. It is free and will look cool on your resume!
 
Note: If you know nothing about git, you can still follow along by simply clicking the Clone or download button here and choosing to download a zip file.

 
1. Log into GitHub with your account
2. Search for the GitHub repository ‘qxf2/wtfiswronghere’
3. Click on the Fork button on the upper right-hand side of the repository’s page
4. Now, you have a fork of our code
5. Make a local copy by cloning your repository
5 a. Create a branch to work ( git checkout master -b fix-challenge-01)
6. In your terminal prompt (git bash, command prompt, etc.), navigate to each challenge directory (e.g.: 01_challenge)
7. Run the one Python script in the challenge directory (python 01_challenge.py)
8. It should throw an error that reads similar to the .png in the challenge directory.

9. Fix the error. To do this, open the wtfiswronghere directory using Visual Studio Code (or your favorite editor)
10. Look carefully at line 27 and the error. You will notice we used only one = to do the check while on line 25 (which worked) we used two equal to symbols.
11. Change line 27 to be elif i%num1==0:
12. Rerun the script (python 01_challenge.py)
13. Rejoice if everything went well! Otherwise, just post the error in the comments. We will help.
14. Update the readme.md with what you just learned and how you solved the problem.
 
OPTIONAL
We’d love it if you practiced a bit of git discipline and checked in your code. Here is how you can do it.
15. Run git status on your command prompt
16. You should see exactly two files changed (01_challenge.py and python 01_readme.md)
17. Commit your code (git commit 01_challenge.py python 01_readme.md -m "Fixed the first challenge" )
18. Push the code to your forked repository (git push origin fix-challenge-01)
19. You should see the command line tell you that it pushed your branch
20. Optional: Visit your GitHub account using a browser and either create a pull request for yourself or navigate to the branch and merge it
 


Problems?

It is hard to write for beginners. I probably missed elaborating on something or perhaps just took a step for granted. So you may be facing problems in spite of following all the steps. Please post any problems you faced in the comments and one of my colleagues will help you out.
 


Leave a Reply

Your email address will not be published. Required fields are marked *