Ash Marz · July 5, 2015 ``from random import *print("ROCK(0) \t PAPER(1) \t SCISSORS(2)")choice = eval(input("Enter your choice: "))if (choice == 0):    print("You chose ROCK")elif (choice == 1):    print("You chose PAPER")elif (choice == 2):    print("You chose SCISSORS")choice1 = randint(0,2)if (choice1 == 0):    print("The computer chose ROCK")elif (choice1 == 1):    print("The computer chose PAPER")elif (choice1 == 2):    print("The computer chose SCISSORS")count = 0while count <= 3:    if choice == 0:        if choice1 == 0:            print("Draw")        if choice1 == 1:            print("You Lose")        if choice1 == 2:            print("You Win")         print("ROCK(0) \t PAPER(1) \t SCISSORS(2)")         choice = eval(input("Enter your choice: "))    if  choice == 1:        if choice1 == 0:            print("You Win")        if choice1 == 1:            print("Draw")        if choice1 == 2:            print("You Lose")    print("ROCK(0) \t PAPER(1) \t SCISSORS(2)")     choice = eval(input("Enter your choice: "))    if choice == 2:        if choice1 == 0:            print("You Lose")        if choice1 == 1:            print("You Win")        if choice1 == 2:            print("Draw")    print("ROCK(0) \t PAPER(1) \t SCISSORS(2)")     choice = eval(input("Enter your choice: "))    count += 1     [/code][/code]``

## Replies

 kevin brasher · July 5, 2015 Hey, you will need to use a for loop. A for loop allows you to complete  a set of actions based on a condition. Chad Batista · July 5, 2015 Here's an idea...``from random import *count = 0while count < 3:    print("ROCK(0) \t PAPER(1) \t SCISSORS(2)")    choice = eval(input("Enter your choice: "))    if (choice == 0):        print("You chose ROCK")    elif (choice == 1):        print("You chose PAPER")    elif (choice == 2):        print("You chose SCISSORS")    choice1 = randint(0,2)    if (choice1 == 0):        print("The computer chose ROCK")    elif (choice1 == 1):        print("The computer chose PAPER")    elif (choice1 == 2):        print("The computer chose SCISSORS")    count = count + 1``I'm sure you can figure out the rest from that. Ash Marz · July 5, 2015 @Chad Batista  I still cannot get it right Tony Stark · July 5, 2015 ``My indentation messed up as I pasted it on here but should hopefully not be confusing'''Guessing you want to play rock paper scissors three times then if score =- 3 player wins or looses?'''import random# keep scorescore = 0# how many times game has been played - for while loopplayed = 0# easy to store the options in the list than typeoptions = ['rock', 'paper', 'scissors']# dictionary to decide who beats whobeats = {'rock': 'scissors', 'paper': 'rock', 'scissors': 'paper'}# self explanatorytext = 'You chose: '# variables to keep what choices the player & computer chose for comparing laterPlayerChoose = ''ComputerChoose = ''while played < 3: # print Round 0, Round 1, etc print("Round ", played) print("ROCK(0) \t PAPER(1) \t SCISSORS(2)") # store choise choice = int(input("Enter your choice: ")) # depending on choice, print what they chose & save it in PlayerChoose variable if choice == 0: print(text + options[0]) PlayerChoose = 'rock' elif choice == 1: print(text + options[1]) PlayerChoose = 'paper' elif choice == 2: print(text + options[2]) PlayerChoose = 'scissors' # computer's choices rand = random.randrange(0, 2) ComputerChoose = options[rand] print('Computer chose ' + ComputerChoose) # the smart bit # for the dictionary, if I do beats[rock] the output is 'scissors' as that's the value # so if player chooses 'paper' then computer can only beat if it chose 'scissors' # as beats[scissors] == paper, read through the code and understand how it works if PlayerChoose == ComputerChoose: print('Tie!') elif PlayerChoose == beats[ComputerChoose]: print('You loose!') elif ComputerChoose == beats[PlayerChoose]: print('You win!') score += 1 played += 1print('You scored: ', score)`` Chad Batista · July 6, 2015 Which part, looping it 3 times? Otto Von Chesterfield · July 6, 2015 Here's a few examples of looping:``max_num = 3#For __ in range(__) loopfor i in range(max_num): #Also range(0, max_num)  print(i)  #Codei = 0#While i < __, ..., i += 1 loopwhile i < max_num:  #Code  print(i)  i += 1``In either case, you should get printed:``012``Hope this helps! Ebenezer Popoola · July 7, 2015 As @Kevin said, try to use a for loop to test it since you are sure about the number of times you expect the loop to run.
• 1

## Python

123,140 followers