0

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.

Chris434
  • 21
  • 1

3 Answers3

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