Sarathlal N

Select random element from a list - Python

import random

items = [1, 2, 3, 4, 5, 6, 7, 8, 9]
random_item = random.choice(items)
print(random_item)

Recent Posts

  1. Solve "ValueError invalid literal for int() with base 10" - Python
  2. Handling dynamic subdomain with Flask - Python
  3. A minimal example about WordPress object cache
  4. Write our first Selenium program with Python 3 & Firefox
  5. Install Geckodriver in Ubuntu & its variants

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.