Ce script fait partie des projets Python de HyperSkill.
j'ai fait toute la formation python de Hyperskill pendant le Confinement 2020.
| # Write your code here | |
| from random import choice | |
| while True: | |
| user_choice = input() | |
| win_situation = {"rock": "scissors", | |
| "paper": "rock", | |
| "scissors": "paper"} | |
| computer_choice = choice(list(win_situation.keys())) | |
| if user_choice not in win_situation.keys(): | |
| msg = "Invalid input" | |
| if user_choice == "!exit": | |
| print("Bye!") | |
| exit(0) | |
| elif user_choice == computer_choice: | |
| msg = f"There is a draw ({computer_choice})" | |
| elif win_situation[user_choice] != computer_choice: | |
| msg = f"Sorry, but computer chose {computer_choice}" | |
| else: | |
| msg = f"Well done. Computer chose {computer_choice} and failed" | |
| print(msg) |
cyvax - 2025