In Python Using the random module write a function removeAnd

In Python

Using the random module, write a function removeAndReturnRandomElement(L) that selects an element from list L at random, removes it from the list and returns it.

Solution

import random
def removeAndReturnRandomElement(L):
element=random.choice(L);
L.remove(element);
return element

In Python Using the random module, write a function removeAndReturnRandomElement(L) that selects an element from list L at random, removes it from the list and

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site