Python Code Works Fine First Time, But Fails Second Time
The first time I run this block of code from Notebook it works fine: #Which letters and how many letters = ['a','b','c'] noOfLetters = len(letters) #Looking for all permutations r
Solution 1:
Assuming "notebook" is Jupyter (previously ipython notebooks), you must be careful that jupyter keeps the state of all variables.
--> that means that the second run starts with variables already initialized at the value they had at the end of the first run.
One way to avoid that is to restart the kernel; another is to delete all variables; one more is to initialize all your variables each time you run.
from the docs:
To restart the kernel (i.e. the computational engine), click on the menu Kernel -> Restart. This can be useful to start over a computation from scratch (e.g. variables are deleted, open files are closed, etc...).
Post a Comment for "Python Code Works Fine First Time, But Fails Second Time"