Search code examples
pythonarraysrandom

How do I select a random element from an array in Python?


The first examples that I googled didn't work. This should be trivial, right?


Solution

  • import random
    
    mylist=['Pinky', 'Blinky', 'Inky', 'Clyde']
    random.choice (mylist)