Sunday 15 January 2012

syntax - Python rock, paper, scissors -


Python is trying to learn and started with it, I keep getting a syntax error while trying to run it.

Rocks: {Rock: Scissors, Paper: Rock, Scissors: Paper} Player_core = 0 Computer_core = 0 Def Start (): "Paper", "Rock", Paper: "Paper", Scissor: "Scissor"} Rule = Play "play, play, play a game of scissors." While the game (): pass score (): Definition: player = move () computer = random. (1, 3) result (player, computer) return Play_again () def move (): while correct: print player = raw_input ("rock = 1 \ n pap = 2 \ n sensor = 3 \ n create a move:"): player = int (player) if player In (1,2,3): return player except ValueError: Print Print "Oh! I did not understand that please enter 1, 2 or 3. "Diff result (player, computer): print" 1 ... "time.sleep (1) print" 2 ... "time.sleep (1) print" 3! "Time If the player [player] == Computer: print" "then" computer game "has been assured of your victory." Player_score + = 1 else: print "You know that you have lost your computer laugh." Def Answer in answer to "answer = raw_input (" Would you like to play again? Y / n: ") Answer (" Y "," Y "," Yes "," Yes "," Absolutely! ") Answer other: print "thank you very much for playing our games! Next time!" Def score (): global player_core, computer_source Rint "high score" print "player:", player_core print "computer:", computer_core if __name__ == '__main__': start ()

1) You have an indentation error:

  try: player = player (player) = if (1, 2, 3) Player: Returning player except the value: Leave the statement leaving the toll # and leave the print "Oh! I did not understand that please enter 1, 2 or 3."   

2) Apart from this:

  If the rule [d Error: If the rule [player] == Computer:   

3) If otherwise: [rule] [player] == Computer: print " Your victory has been assured. " Player_score +.

  if player == computer: print "tie game" = 1 other: # wrong indentation print "You know you're lost while laughing a computer."   

This could be:

  if the rule [player] == Computer: print "Your win is assured." Player_score + = 1 Other: Print "Laughing the computer, you realize that you have lost."    

No comments:

Post a Comment