/
eb
/
python_learn
Обзор
Документация
Войти
/
eb
/
python_learn
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
cycles/game/game.py
25 строк
674 B
EvgeniyBudaev
Initial commit
08 фев 2021, 20:58
08 фев 2021, 20:58
f6afe09
Код
Авторство
О чём код?
import random should_continue = True while should_continue: player_choice = input('Player choice: [R/S/P] ').lower() if player_choice not in ['r', 's', 'p']: print('Incorect input. Try again') continue gen = {1:'r', 2:'s', 3:'p'} comp_choice = gen[random.randint(1,3)] print(f'Comp choise = {comp_choice}') winning_combinations = [('p', 'r'), ('r', 's'), ('s', 'p')] if player_choice == comp_choice: print('Ничья') elif (player_choice, comp_choice) in winning_combinations: print('Вы победили!') else: print('Победил компьютер') should_continue = input('Want to proceed? [y/n]').lower() == 'y'