Skip to content
Sign upLog in
← Back to Community

How to make a random selection from a list in Python?

Profile icon
[deleted]

I am trying to make Rock Paper Scissors but every time the computer is supposed to make a random selection it picks the same one over and over. How do I make it 100% random?

Answered by TheForArkLD [earned 5 cycles]
View Answer
Voters
Profile icon
MironAnanyev
Comments
hotnewtop
Profile icon
TheForArkLD
import math import random choice[math.floor(random.random() * len(choice))]
Profile icon
TheForArkLD

@TheForArkLD
if it solved your problem then, push check mark please.

Profile icon
octopyBot

'''
import random
responses = ['rock', 'paper', 'scissors']
rps = random.choice(responses)
'''

Profile icon
ironblockhd

It works fine for me
IMG_2817

Profile icon
[deleted]

@ironblockhd
do it again, it always chooses rock