I am trying to learn the basics of programming using python, and I am getting to the point where I have to deal with if statements and for loops. The thing is that I am getting a bit confused as to how my code is running. Is there a way to see how my code is being executed line by line; I feel that that would deepen my understanding of why code has to be written a certain way in order for computers to understand what I am trying to accomplish. I dont know if my question makes any sense to you guys, but I hope you can help me. Thanks a lot in advance.
Asked
Active
Viewed 382 times
0
-
Use a debugger or an editor/IDE that comes with one. – Zain Patel Aug 17 '19 at 00:46
-
You can also accept which answer you found best. – new Q Open Wid Aug 17 '19 at 00:56
-
Pycharm is a great choice, they have an excellent debugger and great code completion. As a beginner, it will help you muchly; https://www.jetbrains.com/pycharm/ – SteveJ Aug 17 '19 at 03:23
3 Answers
0
You can use an interactive debugger. Some Python IDEs provide it.
You may want to give VS Code a try. Take a look at the debugger part of the tutorial.

Pierre V.
- 1,625
- 1
- 11
- 14
0
What you are looking for is called a debugger. You can find some online, for example here: https://www.onlinegdb.com/online_python_debugger . Alternatively you can use pdb, the python debugger (the above link is just a friendly wrapper around it), directly from the command line, but if you are new to python and programming I wouldn't recommand it.

Smyler
- 31
- 5
0
Try pdb
.
python -m pdb script.py
More information on How to step through Python code to help debug issues?.
pdb
documentation here.

new Q Open Wid
- 2,225
- 2
- 18
- 34