Skip to content

Instantly share code, notes, and snippets.

@coder-here
Created December 31, 2024 16:41
Show Gist options
  • Select an option

  • Save coder-here/498369972ac3e4f11dc892fa8519bd55 to your computer and use it in GitHub Desktop.

Select an option

Save coder-here/498369972ac3e4f11dc892fa8519bd55 to your computer and use it in GitHub Desktop.
import random
comp_choise = ['rock' , 'papper' , 'scissor']
while True:
user_input = input(f'choose one {comp_choise} ')
if user_input in ['roc','ROCK','r']:
user_input = 'rock'
elif user_input in ['paper','p','pap']:
user_input = 'papper'
elif user_input in ['scisor', 's', 'scissors']:
user_input = f'{comp_choise()}'
else:
print(f'{user_input} is invalid try again ! ')
comp_action = random.choice(comp_choise)
if user_input == comp_choise:
print(f'ur input is {user_input} and comp is also {comp_action} , try ties again ! ')
elif(user_input == 'rock' and comp_action == 'scissor') or \
(user_input == 'scissor' and comp_action == 'papper') or \
(user_input == 'papper' and comp_action == 'rock') :
print(f'ur choose {user_input} beats {comp_action} . user win! ')
else:
print('comp {comp_action} beats {user_input} , comp is win ')
play_again = input("Play again? (y/n): ").lower()
if play_again != "y":
print("Thanks for playing!")
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment