Last active
July 16, 2022 06:15
-
-
Save steezeburger/0c5a856b41f3af4e1dcde9912b411d7f to your computer and use it in GitHub Desktop.
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
from random import randint | |
hands = ['rock', 'scissors', 'paper'] | |
judgements = ['It is a draw.', 'You lost to a computer!', 'You win I guess.'] | |
while True: | |
try: | |
user_input = input('Your weapon of choice: ') | |
user_choice_index = hands.index(user_input.lower()) | |
except ValueError: | |
print(f'{user_input} is not an accepted weapon!') | |
break | |
npc_choice_index = randint(0, 2) | |
npc_choice_label = hands[npc_choice_index] | |
judgement = judgements[user_choice_index - npc_choice_index] | |
top_string = f'# The computer played {npc_choice_label}! #' | |
top_btm_border = '#' * len(top_string) | |
judgement_w_border = f'# {judgement.center(len(top_string) - 4)} #' | |
print(top_btm_border) | |
print(top_string) | |
print(judgement_w_border) | |
print(top_btm_border) | |
print('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment