I am writing a program that plays Rock Paper Scissors with the user. I have to run the program 5 times. And I am using python. Whenever I run the program and type in "R", "S", or "P", the program would result in an error:
TypeError: winOrLose() takes exactly 2 arguments (0 given)
This is my program below:
from myro import *
from random import *
def userOptions():
print "Press R for Rock"
print "Press P for Paper"
print "Press S for Scissors"
choice = raw_input("Your choice is: ")
if choice == "R":
return "Rock"
if choice == "P":
return "Paper"
if choice == "S":
return "Scissors"
else:
userOptions()
def computerRandom():
options = ["Rock", "Paper", "Scissors"]
cGuess = randint(0,2)
return options[cGuess]
def winOrLose(userChoice, computerChoice):
if userChoice == computerChoice:
return "Tie"
if userChoice == "Rock" and computerChoice == "Paper":
return "Computer Wins"
if userChoice == "Paper" and computerChoice == "Scissors":
return "Computer Wins"
if userChoice == "Scissors" and computerChoice == "Rock":
return "Computer Wins"
else:
return "User Wins"
while True:
userChoice = userOptions()
computerChoice = computerRandom()
print "User Chose: ", userChoice
print "Computer Chose: ", computerChoice
result = winOrLose(userChoice, computerChoice)
if result == "Tie":
print "It is a tie"
elif result == "Computer Wins":
print "Computer Wins"
else:
print "User Wins"
def main():
for index in range(1,5,1):
speak("Rock Paper Scissors Shoot")
userOptions()
computerRandom()
winOrLose()
main()
Please someone help me, I am kinda desperate at this moment to figure out how to fix this problem.
Thank you
Aucun commentaire:
Enregistrer un commentaire