On Jun 14, 2016 4:05 PM, "Katelyn O'Malley" <k.omalle...@gmail.com> wrote: > > Hi I am just getting into python and I am trying to create a rock paper > scissor lizard spock game for 3 people and I cannot figure out the scoring > of the players I attached the code below, any help/ideas is much > appreciated. Welcome to python and the tutor list.
I don't know what you mean by "figure out the scoring". Please explain. Did you test the program? Please do that now, fix the problems that you will discover. I don't want to sound discouraging, but there are many problems here. I will list some. Unused items e.g. random. Undefined names e.g. difference. Unnecessary function calls e.g. str, int Repeated code. I assume this is your first attempt at programming. Have you gone through any tutorials? It would be good to start with something simpler. I suggest you sit with pencil and paper and walk through the program line by line. What happens If a player enters something other than a valid choice? We want you to succeed. But you must study proper coding techniques. Take a course, read a book, get a simpler program running. > > import random > > number_of_games = 3 > > print("Player 1 please choose rock , paper , scissors , lizard, or spock > (in lower case please)") > choice1 = input("What do you choose? ") > player1_choice = str(choice1) > print("Player 2 please choose rock , paper , scissors , lizard, or spock > (in lower case please)") > choice2 = input("What do you choose? ") > player2_choice = str(choice2) > print("Player 3 please choose rock , paper , scissors , lizard, or spock > (in lower case please)") > choice3 = input("What do you choose? ") > player3_choice = str(choice3) > def name_to_number(name): > if name == "rock": > name = 0 > return name > elif name == "spock": > name = 1 > return name > elif name == "paper": > name = 2 > return name > elif name == "lizard": > name = 3 > return name > elif name == "scissors": > name = 4 > return name > > def number_to_name(number): > if number == 0: > number = "rock" > return number > elif number == 1: > number = "spock" > return number > elif number == 2: > number = "paper" > return number > elif number == 3: > number = "lizard" > return number > elif number == 4: > number = "scissors" > return number > > player1_number = name_to_number(choice1) > player2_number = name_to_number(choice2) > player3_number = name_to_number(choice3) > > while number_of_games > 0: > number_of_games -= 1 > print("Player 1 choice is: " + player1_choice) > print("Player 2 choice is: " + player2_choice) > print("Player 3 choice is: " + player3_choice) > if (int(player1_number) - player2_number) % 5 >=3: > print("Player 1 wins!") > elif difference >=2: > print("Player 2 wins!") > elif difference <=1: > print ("Player 3 wins!") > elif difference == 0: > print("It's a tie! You have %d tries left..." % number_of_games) > number_of_games = '' > else: > print("You lost to the Computer. You have %d games left..." % > number_of_games) > number_of_games = '' > break > > while number_of_games >0: > number_of_games -=1 > choice1 = input("What do you choose? ") > player1_choice = str(choice1) > print("Player 1 choice is: " + player1_choice) > choice2 = input("What do you choose? ") > player2_choice = str(choice2) > print("Player 2 choice is: " + player2_choice) > choice3 = input("What do you choose? ") > player3_choice = str(choice3) > print("Player 3 choice is: " + player3_choice) > if difference >=3: > print("Player 1 wins!") > elif difference >=2: > print("Player 2 wins!") > elif difference <=1: > print ("Player 3 wins!") > elif difference == 0: > print("It's a tie! You have %d tries left..." % number_of_games) > number_of_games = '' > else: > print("You lost to the Computer. You have %d games left..." % > number_of_games) > number_of_games = '' > break > > while number_of_games >0: > number_of_games -=1 > choice1 = input("What do you choose? ") > player1_choice = str(choice1) > print("Player 1 choice is: " + player1_choice) > choice2 = input("What do you choose? ") > player2_choice = str(choice2) > print("Player 2 choice is: " + player2_choice) > choice3 = input("What do you choose? ") > player3_choice = str(choice3) > print("Player 3 choice is: " + player3_choice) > if difference >=3: > print("Player 1 wins!") > elif difference >=2: > print("Player 2 wins!") > elif difference <=1: > print ("Player 3 wins!") > elif difference == 0: > print("It's a tie! You have %d tries left..." % number_of_games) > number_of_games = '' > else: > print("You lost to the Computer. You have %d games left..." % > number_of_games) > number_of_games = '' > break > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor