Ad
Sets
Code
Diff
  • def NotDumbRockPaperScissors(player1, player2):
        rock = {"paper"}
        paper = {"scissors"}
        scissors = {"rock"}
        # set variable names to lowercase
        if player1.lower() in eval(player2.lower()):
            return "Player 1 wins"
        elif player2.lower() in eval(player1.lower()):
            return "Player 2 wins"
        # converted the input args into lowercase for more consistent comparisons
        else:
            return "Draw"
     
    
    • def dumbRockPaperScissors(player1, player2):
    • Rock = {"Paper"}
    • Paper = {"Scissors"}
    • Scissors = {"Rock"}
    • if player1 in eval(player2):
    • def NotDumbRockPaperScissors(player1, player2):
    • rock = {"paper"}
    • paper = {"scissors"}
    • scissors = {"rock"}
    • # set variable names to lowercase
    • if player1.lower() in eval(player2.lower()):
    • return "Player 1 wins"
    • elif player2 in eval(player1):
    • elif player2.lower() in eval(player1.lower()):
    • return "Player 2 wins"
    • # converted the input args into lowercase for more consistent comparisons
    • else:
    • return "Draw"

I removed the unnecessary import ('re' library, originally) and got the job done with the python built in functions only.

Code
Diff
  • def disemvowel(string):
        return ''.join([i for i in string if i.lower() not in "aieou"])
    
    • import re
    • def disemvowel(string_):
    • return re.sub(r'[aeiouAEIOU]', "", string_)
    • def disemvowel(string):
    • return ''.join([i for i in string if i.lower() not in "aieou"])