lundi 11 juillet 2022

Python - Random module if block print issue

import random

print("Welcome to the game of Stone Paper Scissor!")
num=int(input("How many games do you wanna play ? Choose odd number only! "))
print(f"It is going to be best of {num} games")

for i in range(0,num):
    player=input("Play your move \n")
    comp=("R","P","S")
    comp=print(random.choice(comp))

    if player==comp:
        print("Tie")
    
    elif player=="R" and comp=="S":
        print("Player wins")

    elif player=="R" and comp=="P":
        print("Computer wins")
        
    elif player=="S" and comp=="P":
        print("Player wins")
    
    elif player=="S" and comp=="R":
        print("Computer wins")

    elif player=="P" and comp=="S":
        print("Computer wins")

    elif player=="P" and comp=="R":
        print("Player wins")

The code is getting executed but there is no printing of the results.i.e(Computer wins or player wins or Tie)

Please let me know if there is any fundamental error which needs to be corrected.




Aucun commentaire:

Enregistrer un commentaire