Last active
July 6, 2020 09:53
-
-
Save mburakerman/cce61bc1dd1f56e120e7f221e76713a2 to your computer and use it in GitHub Desktop.
python rock-scissors-paper game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
game = ["rock", "scissors", "paper"] | |
human_val = False | |
print("enter rock, scissors or paper") | |
while human_val == False: | |
human_val = input() | |
computer_val = random.choice(game) | |
print(f"π» computer: {computer_val}") | |
# check if valid | |
if human_val not in game: | |
print("please type rock, scissors or paper correctly\n") | |
if human_val == computer_val: | |
print("tie\n") | |
# rock | |
elif human_val == "rock": | |
if computer_val == "scissors": | |
print("π you win!\n") | |
elif computer_val == "paper": | |
print("π computer wins!\n") | |
# scissors | |
elif human_val == "scissors": | |
if computer_val == "rock": | |
print("π computer wins!\n") | |
elif computer_val == "paper": | |
print("π you win!\n") | |
# paper | |
elif human_val == "paper": | |
if computer_val == "rock": | |
print("π you win!\n") | |
elif computer_val == "scissors": | |
print("π computer wins!\n") | |
human_val = False | |
computer_val = random.choice(game) | |
print("enter rock, scissors or paper") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment