Answers for "pick random index from array python"

23

how to randomly choose from a list python

random.choice(name of list)
Posted by: Guest on December-04-2019
4

choose random index from list python

import random  # Don't forget to install it first with pip install random

ahahfunny = ['ahah ', 'copy-', 'paste ', 'stack overflow',' go ', 'brrr']
#  the biggest index in this list above is 5 (0 being 1 in programming)

print(ahahfunny[random.randint(0, 5)]  # I like this way,
      
print(random.choice(ahahfunny)) # But this way is WAY thiccer...
Posted by: Guest on July-08-2020

Code answers related to "pick random index from array python"

Python Answers by Framework

Browse Popular Code Answers by Language