Answer the question
In order to leave comments, you need to log in
How to prevent the list from growing?
I have a function that, for example, selects random numbers and adds to an already existing empty list. But at the same time, I need this list to be constantly cleared. And when I want to run the function again. More numbers are added to the old numbers. And the list of conditional 3 numbers already consists of 6. and I need it to be "updated" as it were.
I would say that variables can be made not global, but local, that is, write them in the same function, then a = will be constantly called list(), and there will be no problems.
But maybe there are other options?
Answer the question
In order to leave comments, you need to log in
list.clear()
Can you read what are, at least, built-in functions and their methods?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question