Hello everyone,
I know that lists are mutable. So, whenever I want them to start as empty lists, I set them to [ ]. For instance, if I am working with a list named my_list, and I want it to start anew at every new function call, I do something like this: another_list = my_list[:], then I set my_list = [ ] and then return another_list. This has been working for me. However, today it doesn't work quite well. It accumulates the previous values together with the new values. Though when I call it with a directory name, it works well, but when I run the grade.py, I see that the first one is correct, then from there it accumulates the previous values and the current ones. For clarity, the error is relating to the ex4 of the simulation exam. If anyone wants to help and wants to see my code, please don't hesitate to let me know!. I am only and solely interested to know why this happens, and how to avoid similar one during exams. Is it the grade.py that does this, and if yes, how to solve it then?
Thanks to anyone wanting to help, and have a nice holiday!
I know that lists are mutable. So, whenever I want them to start as empty lists, I set them to [ ]. For instance, if I am working with a list named my_list, and I want it to start anew at every new function call, I do something like this: another_list = my_list[:], then I set my_list = [ ] and then return another_list. This has been working for me. However, today it doesn't work quite well. It accumulates the previous values together with the new values. Though when I call it with a directory name, it works well, but when I run the grade.py, I see that the first one is correct, then from there it accumulates the previous values and the current ones. For clarity, the error is relating to the ex4 of the simulation exam. If anyone wants to help and wants to see my code, please don't hesitate to let me know!. I am only and solely interested to know why this happens, and how to avoid similar one during exams. Is it the grade.py that does this, and if yes, how to solve it then?
Thanks to anyone wanting to help, and have a nice holiday!