jeudi 27 février 2020

How to make my rock, paper, scissor run more than once - Python

below is what I have so far, I need to implement function simul() that takes as input an integer n and simulates n rounds of Rock, Paper, Scissors between players Player 1 and Player 2. Any tips would be appreciated

import random
def simul(n):

    p1 = random.choice("RPS") 
    p2 = random.choice("RPS") 

    if p1 == p2:
       print("Tie")
    elif (p1 == "R" and p2 == "S") or (p1 == "S" and p2 =="P") or (p1 == "P" and p2 == "R"):
       print("Player 1 wins")
    else:
       print("Player 2 wins")



Aucun commentaire:

Enregistrer un commentaire