не работает камень ножницы бумага. поправьте пж!

жус

Новичок
Пользователь
Авг 3, 2023
2
0
1
написал за несколько минут. не проверял в течении всего времени. запусаю - ошибка. каждый раз, исправляя ее появлялась новая

перемены названы правильно!!

import random
rock = 'rock'
paper = 'paper'
scissors = 'scissors'
pl_win = 'player won'
pc_win = 'player lose'
dr = 'draw'
def play_in(player_choice):
player_choice = input()
print('player:', player_choice)

def play_out(pc_choice):
pc_choice = random.random(paper,rock,scissors)
print('computer:',pc_choice)
print(rock,scissors,paper)
print('print 0 to break')
while True:
play_in(player_choice=input())
play_out(pc_choice=random.random(rock,paper,scissors))
########################### player lose ########################:
if play_in(player_choice=rock) and play_out(pc_choice=paper):
print(pc_win)
if play_in(player_choice=paper) and play_out(pc_choice=scissors):
print(pc_win)

if play_in(player_choice=scissors) and play_out(pc_choice=rock):
print(pc_win)

########################### player won ##############################:
if play_in(player_choice=paper) and play_out(pc_choice=rock):
print(pl_win)
if play_in(player_choice=scissors) and play_out(pc_choice=paper):
print(pl_win)
if play_in(player_choice=rock) and play_out(pc_choice=scissors):
print(pl_win)
########################### draw ##############################:
if play_in(player_choice=paper) and play_out(pc_choice=paper):
print(dr)
if play_in(player_choice=scissors) and play_out(pc_choice=scissors):
print(dr)
if play_in(player_choice=rock) and play_out(pc_choice=rock):
print(dr)
 

жус

Новичок
Пользователь
Авг 3, 2023
2
0
1
Python:
import random

rock = 'rock'
paper = 'paper'
scissors = 'scissors'
pl_win = 'player won'
pc_win = 'player lose'
dr = 'draw'

def play_in(player_choice):
    player_choice = input()
    print('player:', player_choice)


def play_out(pc_choice):
    pc_choice = random.random(paper,rock,scissors)
    print('computer:',pc_choice)

print(rock,scissors,paper)
print('print 0 to break')

while True:
    play_in(player_choice=input())
    play_out(pc_choice=random.random(rock,paper,scissors))

########################### player lose ########################:

    if play_in(player_choice=rock) and play_out(pc_choice=paper):
        print(pc_win)

    if play_in(player_choice=paper) and play_out(pc_choice=scissors):
        print(pc_win)
        
    if play_in(player_choice=scissors) and play_out(pc_choice=rock):
        print(pc_win)
    
########################### player won ##############################:

    if play_in(player_choice=paper) and play_out(pc_choice=rock):
        print(pl_win)

    if play_in(player_choice=scissors) and play_out(pc_choice=paper):
        print(pl_win)

    if play_in(player_choice=rock) and play_out(pc_choice=scissors):
        print(pl_win)

########################### draw ##############################:

    if play_in(player_choice=paper) and play_out(pc_choice=paper):
        print(dr)

    if play_in(player_choice=scissors) and play_out(pc_choice=scissors):
        print(dr)

    if play_in(player_choice=rock) and play_out(pc_choice=rock):
        print(dr)
 

regnor

Модератор
Команда форума
Модератор
Июл 7, 2020
2 661
474
83
Python:
import random

rock = 'rock'
paper = 'paper'
scissors = 'scissors'
pl_win = 'player won\n'
pc_win = 'player lose\n'
dr = 'draw\n'

while True:
    print(rock, scissors, paper)
    print('print 0 to break')

    play_in = input("Enter your choice: ")
    play_out = random.choice([rock, paper, scissors])

    if play_in == "0":
        break

    ########################### player lose ########################:

    if play_in == rock and play_out == paper:
        print(pc_win)

    if play_in == paper and play_out == scissors:
        print(pc_win)

    if play_in == scissors and play_out == rock:
        print(pc_win)

    ########################### player won ##############################:

    if play_in == paper and play_out == rock:
        print(pl_win)

    if play_in == scissors and play_out == paper:
        print(pl_win)

    if play_in == rock and play_out == scissors:
        print(pl_win)

    ########################### draw ##############################:

    if play_in == play_out:
        print(dr)
 

4olshoy_blen

Популярный
Пользователь
Ноя 13, 2022
423
115
43
Python:
import random

rock, paper, scissors = 'rock', 'paper', 'scissors'
player_won_list = [(paper, rock), (scissors, paper), (rock, scissors)]
player_lose_list = [(rock, paper), (paper, scissors), (scissors, rock)]
prompt = ' '.join([rock, paper, scissors]) + '\nprint 0 to break\nEnter your choice: '

while (play_in := input(prompt)) != "0":
    print(f'Computer chose:', play_out := random.choice([rock, paper, scissors]))

    if (play_in, play_out) in player_won_list:
        print('player won\n')

    elif (play_in, play_out) in player_lose_list:
        print('player lose\n')

    elif play_in == play_out:
        print('draw\n')

    else:
        print('Enter correct word\n')
 
  • Мне нравится
Реакции: regnor

Форум IT Специалистов