Answers for "choose random integer from list"

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
1

python random generator from list

import random
n = random.random()
print(n)
Posted by: Guest on June-01-2020

Code answers related to "choose random integer from list"

Python Answers by Framework

Browse Popular Code Answers by Language