0
Is removing certain elements from a list by random.choice possible in Python?
Say I had a program make a random choice and it selected the third element in the list. The third element would be removed from the list. In response, the fourth, fifth and sixth elements would also be removed from the list. How can I make that happen?
1 ответ
+ 2
So you want to remove all elements after the chosen one (including the chosen one)?
from random import randrange
del your_list[randrange(len(yourlist)):]