Solution: 1. Write code in python shell. If you accidentally make a mistake, you can modify it directly, and it is convenient to change lines, which is very convenient. 2. Writing code in ipython is very helpful for beginners to practice the basics of python.
#In the process of learning python and writing code by hand, errors will inevitably occur. If you write it on the command line or in the Python interactive environment, you can only run the code once each time. If you want to modify the code, you need to rewrite it. How to deal with this situation?
1. Write code in python shell, as follows
Write code in shell. If you accidentally make a mistake, you can modify it directly, and It’s very convenient to change lines.
2. Write code in ipython.
#ipython is very helpful for beginners to practice the basics of python.
The above is the detailed content of What should I do if I make a mistake when writing python code?. For more information, please follow other related articles on the PHP Chinese website!