Reputation: 21
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.
Upvotes: 0
Views: 1135
Reputation: 2283
Try pdb
.
python -m pdb script.py
More information on How to step through Python code to help debug issues?.
pdb
documentation here.
Upvotes: 0
Reputation: 31
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.
Upvotes: 0
Reputation: 1625
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.
Upvotes: 0