vendredi 9 juillet 2021

How do I fix this IndexError:List out of range

I am a beginner to Python so the answer to this question might be stupidly simple but I just cant seem to figure it out.

I am making a simple Rock,Paper,Scissors game And imported random and randint to randomise the choice the ‘computer’ makes but after my programme runs once or twice it starts giving ‘IndexError: list index out of range’

I hope you can help me solve this.

A section of my code is as follows:

from random import randint
import time
import sys 

#Creating a list of possibilities
x=['Rock','Paper,''Scissors']

#Computer making a random choice
computer=x[randint(0,2)]

#This sets player to false to help in our While loop
player= False

while player==False:



Aucun commentaire:

Enregistrer un commentaire