0

これが私のコードです:

from random import*
from myro import*
from math import*

def computerChoice():
   computer = randint(0,2)
   if (computer == 0):
     choice = "rock"
   elif(computer == 1):
     choice = "paper"
   else:
     choice = "scissors"

  return choice

def userGuess():
     print " R = Rock"
     print " P = Paper"
     print " S = Scissors"

     userChoice = raw_input("Enter R, P, or S: ")

     return userChoice

def calculate(userChoice, choice):

    userNameWins = 0
    computerWins = 0
    draws = 0

    if(userChoice == "R" and choice == "paper"):
       speak("scribbler wins")
       computerWins = computerWins + 1
    elif(userChoice== "R" and choice == "scissors"):
       speak( "you win")
        userNameWins = userNameWins + 1
    elif(userChoice== "P" and choice == "rock"):
       speak("you win")
       userNameWins = userNameWins + 1
    elif(userChoice== "P" and choice == "scissors"):
       speak("scribbler wins")
       computerWins = computerWins + 1
    elif(userChoice == "S" and choice == "rock"):
       speak("scribbler wins")
       computerWins = computerWins + 1
    elif(userChoice == "S" and choice == "paper"):
       speak("you win")
       userNameWins = userNameWins + 1
    else:
       speak("Draw")
       draws = draws + 1

    return userNameWins, computerWins, draws

def printResults(userNameWins, computerWins, draws)
    # insert code for print statement

def main():

    for x in range (5):
         speak("Rock Papers Scissors ")
         userChoice = userGuess()
         choice = computerChoice()
         calculate(userChoice,choice)
    printResults (userNameWins, computerWins, draws) 

いくつかの変数を定義しようとするとエラーが発生しますが、その理由がわかりません。によって返された結果を適切に出力する関数が必要ですcalculate()

4

2 に答える 2