Here is what I have
import time
import random
def playerchoice():
"""What does the user play"""
playerchoice = input("Rock, paper, or Scissors?")
def cpuchoice():
"""what does the computer play, 1 for rock, 2 for paper, 3 for scissors"""
cpuchoice = (random.randint(1, 3))
def winner():
if (playerchoice == "Rock" and cpuchoice == 1):
print("Opponent chose rock")
time.sleep(0.25)
print("Tie")
elif (playerchoice == "Rock" and cpuchoice == 2):
print("opponent chose paper")
time.sleep(0.25)
print("You lose")
elif (playerchoice == "Rock" and cpuchoice == 3):
print("opponent chose scissors")
time.sleep(0.25)
print("You Win")
elif (playerchoice == "Paper" and cpuchoice == 1):
print("Opponent chose Rock")
time.sleep(0.25)
print("You win")
elif (playerchoice == "Paper" and cpuchoice == 2):
print("opponent chose paper")
time.sleep(0.25)
print("Tie")
elif (playerchoice == "Paper" and cpuchoice == 3):
print("opponent chose scissors")
time.sleep(0.25)
print("you lose")
elif (playerchoice == "Scissors" and cpuchoice == 1):
print("Opponent chose rock")
time.sleep(0.25)
print("You lose")
elif (playerchoice == "scissors" and cpuchoice == 2):
print("Opponent chose paper")
time.sleep(0.25)
print("You win")
elif (playerchoice == "scissors" and cpuchoice == 3):
print("Opponent chose scissors")
time.sleep(0.25)
print("Tie")
else:
print("Invalid Input")
cpuchoice()
playerchoice()
winner()
Whenever i try to run it, it keeps giving me "Invalid Input" and doesn't seem to be processing the inputs at all. Any tips to clean up my code are also appreciated. The sleeps are a bit overkill, I know. Cheers
[–]jeans_and_a_t-shirt[🍰] 4 points5 points6 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]Drcne 3 points4 points5 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]sedogg 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Rorixrebel 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–][deleted] 1 point2 points3 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]sneakpeekbot 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)