ДЗ3

mail@pastecode.io avatar
unknown
python
a month ago
1.5 kB
2
Indexable
Never
import random


def game(choice, result) -> None:
    print()
    print("=====Start Game rock, paper, scissors=====")
    print()

    computer_choice = random.choice("rps")

    user_choise_filtered = str.lower(choice)

    print("--------------------------------")
    print("Your select – ", str.capitalize(choice))
    print("Computer select —", str.capitalize(computer_choice))
    if str.lower(choice) == computer_choice:
        print("Result of game – Draw")
    elif str.lower(choice) == "r" and computer_choice == "p":
        result["computer"] += 1
        print("------Computer Wins------")
    elif str.lower(choice) == "r" and computer_choice == "s":
        result["player"] += 1
        print("------Player Wins------")
    elif str.lower(choice) == "p" and computer_choice == "s":
        result["computer"] += 1
        print("------Computer Wins------")
    elif str.lower(choice) == "p" and computer_choice == "r":
        result["player"] += 1
        print("------Player Wins------")
    elif str.lower(choice) == "s" and computer_choice == "r":
        result["computer"] += 1
        print("------Computer Wins------")
    elif str.lower(choice) == "s" and computer_choice == "p":
        result["player"] += 1
        print("------Player Wins------")

    print("Score: computer", result["computer"], "—", result["player"], "Player")


result = {"computer": 0, "player": 0}
choise = input("Select R/P/S – ")
game(choice=choise, result=result)
Leave a Comment