Help with RPS.py


#1

help, please.
What wrong with my code, because the error is:

$ python RPS.py
Traceback (most recent call last):
File “RPS.py”, line 38, in
play_RPS()
TypeError: play_RPS() takes exactly 2 arguments
(0 given)
$

‘’’
This program will play with you in Rock-Paper-Scissors
‘’’

from random import randint
options = [“ROCK”, “PAPER”, “SCISSORS”]
message = {
“tie”: “Yawn it’s a tie!”,
“won”: “Yay you won!”,
“lost”: “Aww you lost!”
}

def decide_winner(user_choice, computer_choice):
print “You selected: %s” % user_choice
print “Computer selected: %s” % computer_choice

if user_choice == computer_choice:
print message[“tie”]

elif user_choice == options[0] and computer_choice == options[2]:
print message[“won”]

elif user_choice == options[1] and computer_choice == options[0]:
print message[“won”]

elif user_choice == options[2] and computer_choice[1]:
print message[“won”]

else:
print message[“lost”]

def play_RPS(user_choice, computer_choice):
user_choice = raw_input("Enter Rock, Paper, or Scissors: ")
user_choice = user_choice.upper()
computer_choice = options[randint(0,2)]
decide_winner(user_choice, computer_choice)

play_RPS()


#2

Hi there.

The console is telling you what the problem is quite plainly:

TypeError: play_RPS() takes exactly 2 arguments (0 given)

You’ve defined your function as def play_RPS(user_choice, computer_choice):, but then called it as play_RPS().

Can you see why you’re getting the error? :slight_smile:


#3

Ohhh, thanks, now it is working. I found one more mistake. Thank you again :grinning:


#4

No problemo. :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.