Randint takes 3 argument (2 given)


#1

hello,

i have this error message when i do this exercice : https://www.codecademy.com/courses/learn-python/projects/rock-paper-scissors?action=resume_content_item

randint takes 3 argument (2 given)
how can I solve that please ?

Thanks



""" Rock, Paper, Scissor"""

from random import randint

options= ["ROCK","PAPER","SCISSOR"]


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 "you selected : %s" % computer_choice
  return decide_winner(user_choice, computer_choice)

def decide_winner(user_choice) :
  if computer_choice == user_choice :
    print "tie"[key]

  elif user==option["ROCK"] and computer ==option["SCISSOR"] :
    print "won"[key]
    
  elif user ==option["PAPER"]and computer ==option["rock"]:
    print "won"[key]
      
  elif user==option["SCISSORS"] and computer ==option["PAPER"]:
    print "won"[key]
        
  else :
    print "lost"[key]
          
      
def play_RPS():
  user_choice ="enter Rock, Paper, or Scissors : "
  user_choice.upper()
  
  computer_choice = options[randint(0-2)]
  decide_winner (user_choice, computer_choice)

play_RPS()



#2

To separate arguments at function call you should use a comma, see the documentation:

https://docs.python.org/2/library/random.html#random.randint


#3

i think i arranged the code but i now have global user not defined sometimes

""" Rock, Paper, Scissor"""

from random import randint

options= ["ROCK","PAPER","SCISSOR"]


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 "you selected : %s" % computer_choice
  return decide_winner(user_choice, computer_choice)

def decide_winner(user_choice, computer_choice) :
  if user_choice == computer_choice :
    print message["tie"]

  elif user==option["ROCK"] and computer==option["SCISSOR"] :
    print message["won"]
    
  elif user ==option["PAPER"]and computer ==option["ROCK"]:
    print message["won"]
      
  elif user==option["SCISSOR"] and computer ==option["PAPER"]:
    print message["won"]
        
  else :
    print message["lost"]
          
      
def play_RPS():
  user_choice =raw_input("enter Rock, Paper, or Scissor :")
  user_choice = user_choice.upper()
  
  computer_choice = options[randint(0,2)]
  decide_winner (user_choice, computer_choice)

play_RPS()

#4

the only time this error doesn’t occur is when the result is a tie, so that says something about the other comparison operations of your decide_winner function


#5

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