1
1
1Tima12020-05-02 23:00:13
Python
1Tima1, 2020-05-02 23:00:13

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

1 answer(s)
I
Ivan Yakushenko, 2020-05-02
@1Tima1

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 question

Ask a Question

731 491 924 answers to any question