I made the game rock, paper or scissors. I want to implement a game counter, but I can't figure out how to make it work. It is stopped at 1. I want to play more games and the counter to show me the numbers of played games.
import random
stop = False
while (not stop):
games_count = 0
you = input('Player 1: Please type your choice: rock, paper or scissors: ')
oponent = ['rock', 'paper', 'scissors']
choice = random.choice(oponent)
games_count += 1
print('the oponent choice is: ', choice)
if choice == you:
print('DRAW GAME')
elif choice == 'rock' and you == 'paper':
print('YOU LOST')
elif choice == 'rock' and you == 'scissors':
print('YOU WON')
elif choice == 'paper' and you == 'rock':
print('YOU WON')
elif choice == 'paper' and you == 'scissors':
print('YOU LOST')
elif choice == 'scissors' and you == 'rock':
print('YOU LOST')
elif choice == 'scissors' and you == 'paper':
print('YOU WON')
else:
print('Wrong answer, please type rock, paper or scissors in your next attempt!')
answer = input('Do you want to start a new game? (y for yes, any for no): ')
if answer == 'y':
print('New game will start')
print('jocuri terminate: ',games_count)
elif answer == 'no':
stop = True
print('GAME OVER')
else:
print('Wrong answer, please type Yes or No in your next attempt!')
stop = True
Your counter is reinitialized to 0 at each iteration because it is inside your loop.
while not stop:
games_count = 0
...
Instead, initialize it outside the loop.
games_count = 0
while not stop:
...
As a sidenote, you might want to look to other implementations of rock-paper-scissor that do not rely on a big list of if-statement.
Related
This is the code that I wrote for a very basic rock paper scissors game.
However when I run the code. It doesn't always print the outcome of the game, ie. You win!, You lose or tie. I am not quite sure why this is the case. HELP!![1]
`
start_game = input('Type start to start game:').lower()
import random
def play():
user = input("'rock' , 'paper', 'scissors' ").lower()
if user == 'quit':
print("Game ended :(")
exit()
computer = random.choice(['rock', 'paper','scissors'])
print(computer)
if user == computer:
return 'tie'
elif not user == is_win(user, computer):
return 'You win!'
else:
return 'You lost!'
def is_win(player,opponent):
if (player == 'rock'and opponent == 'scissors') or (player == 'scissors'and opponent == 'paper') or \
(player=='paper' and opponent == 'rock'):
return True
print(play())
while True:
if start_game != 'start':
start_game = input('Sorry i dont understand please try again:')
else:
print(play())
output:
Type start to start game:srt
Sorry i dont understand please try again:start
'rock' , 'paper', 'scissors' rock
paper
`
The logic to decide the winner is slightly wrong. The object user just contains the user's choice. The function is_win should return a boolean. You do return True when the user wins, but when he loses, you're recalling the original calling function.
start_game = input('Type start to start game:').lower()
import random
def play():
user = input("'rock' , 'paper', 'scissors' ").lower()
if user == 'quit':
print("Game ended :(")
exit()
computer = random.choice(['rock', 'paper','scissors'])
print(computer)
if user == computer:
return 'tie'
elif is_win(user, computer):
return 'You win!'
else:
return 'You lost!'
def is_win(player,opponent):
if (player == 'rock'and opponent == 'scissors') or (player == 'scissors'and opponent == 'paper') or \
(player=='paper' and opponent == 'rock'):
return True
return False
while True:
if start_game != 'start':
start_game = input('Sorry i dont understand please try again:')
else:
print(play())
Try making the above changes and see if it works for you.
You are using is_win() function before defining it!
define the function before play function!
consider this
start_game = input('Type start to start game:').lower()
import random
def is_win(player,opponent):
if (player == 'rock'and opponent == 'scissors') or (player == 'scissors'and opponent == 'paper') or \
(player=='paper' and opponent == 'rock'):
return True
print(play())
def play():
user = input("'rock' , 'paper', 'scissors' ").lower()
if user == 'quit':
print("Game ended :(")
exit()
computer = random.choice(['rock', 'paper','scissors'])
print(computer)
if user == computer:
return 'tie'
elif not user == is_win(user, computer):
return 'You win!'
else:
return 'You lost!'
while True:
if start_game != 'start':
start_game = input('Sorry i dont understand please try again:')
else:
print(play())
what is that print(play()) for? You are running another round of the game inside an unfinished round. I think you should return False instead of that and also change the 'elif' condition:
start_game = input('Type start to start game:').lower()
import random
def play():
user = input("'rock' , 'paper', 'scissors' ").lower()
if user == 'quit':
print("Game ended :(")
exit()
computer = random.choice(['rock', 'paper','scissors'])
print(computer)
if user == computer:
return 'tie'
elif is_win(user, computer):
return 'You win!'
else:
return 'You lost!'
def is_win(player,opponent):
if (player == 'rock'and opponent == 'scissors') or (player == 'scissors'and opponent == 'paper') or \
(player=='paper' and opponent == 'rock'):
return True
return False
while True:
if start_game != 'start':
start_game = input('Sorry i dont understand please try again:')
else:
print(play())
Here is my code. I already finish the win function call gameplay(Rock beats scissors. Scissors beats paper. Paper beats rock) and asking the player to play again function call replay. However, I didn't know how to complete the replay function into the main class.
def gameplay(userinput1,userinput2):
if userinput1 == 'Rock' and userinput2 == 'Scissors':
print('Player 1 win')
elif userinput1 == 'Rock' and userinput2 == 'Paper':
print('Player 2 win')
elif userinput1 == 'Rock' and userinput2 == 'Rock':
print('Tie')
elif userinput1 == 'Paper' and userinput2 == 'Rock':
print('Player 1 win')
elif userinput1 =='Paper' and userinput2 == 'Scissors':
print('Player 2 win')
elif userinput1 =='Paper' and userinput2 == 'Paper':
print('Tie')
elif userinput1 == 'Scissors' and userinput2 == 'Paper':
print('Player 1 win')
elif userinput1 == 'Scissors' and userinput2 == 'Rock':
print('Player 2 win')
elif userinput1 =='Scissors' and userinput2 == 'Scissors':
print('Tie')
def replay():
return input('Do you want to play again? Y or N:').lower().startswith('y')
userinput1 = str(input('Your are player1, Enter Rock, Scissors or Paper :'))
userinput2 = str(input('Your are player2,Enter Rock, Scissors or Paper :'))
gameplay(userinput1,userinput2)
Your questions is a little unclear but from what I understood, you should make a loop that calls gameplay and replay. (like #Daniel said) Kind of like this:
while True:
userinput1 = input('Your are player1, Enter Rock, Scissors or Paper :')
userinput2 = input('Your are player2,Enter Rock, Scissors or Paper :')
gameplay(userinput1,userinput2)
if replay() == False:
break
If you have any confusion, ask away!
Edit: Thanks #AndressaCabistani. The input function returns a str type, so we don't need to convert a str into a str.
You can also do this without a while loop, using recursion. Also, simplified the main game function:
def game(p1, p2):
win = ('rock','scissors'),('scissors','paper'),('paper','rock')
p1, p2 = map(lambda x: x.lower().strip(), [p1, p2])
if p1 == p2:
return 'tie!'
elif (p1, p2) in win:
return f'player 1 wins, {p1} beats {p2}'
elif (p2, p1) in win:
return f'player 2 wins, {p2} beats {p1}'
else:
return f'invalid choice(s): {p1}, {p2}'
def _again():
resp = input('play again?')
return resp.lower().strip()[0] == 'y'
def play():
p1 = input('player 1:\n')
p2 = input('player 2:\n')
print(game(p1, p2))
if _again():
play()
I'm quite new to coding, and I've been trying to make a text-based game with a menu. The game itself works fine, but once I try to incorporate a menu, i get the error "NameError: free variable 'player_one_rps' referenced before assignment in enclosing scope".
I have been googling it like a mad for some time now, but the few answers I find uses too advanced code for me to understand it yet.
(I tried changing the scopes and indents, I tried calling different functions at different indents, I tried assigning an argument to the functions, also, to have the main menu as the last function in the code – the list goes on..)
Here is the code for the menu and game option 1:
def main():
print("\t\t*** Welcome to this totally adequate game! ***")
def game_menu():
"""Displays game menu and prompts user for input"""
menu_choice = input("""What do you want to do?
1 - One player: rock, paper, scissor, lizard, spock
2 - Two player: rock, paper, scissor, lizard, spock
3 - Surprise! Bonus feature
4 - User guide
5 - Quit
Enter the menu number to access: """)
while True:
if menu_choice == "1":
print("One player: rock, paper, scissor, lizard, spock")
player_one_rps()
break
elif menu_choice == "2":
print("Two player: rock, paper, scissor, lizard, spock")
player_two_rps()
break
elif menu_choice == "3":
print("Surprise! Bonus feature")
dad_jokes()
break
elif menu_choice == "4":
print("User guide")
user_info()
elif menu_choice == "5":
print("Quit game")
exit()
elif menu_choice != 1 - 5:
print("Error, choose a valid number")
# print(menu_choice)
game_menu()
main()
# First game
def player_one_rps():
"""One player rock, paper, scissor, lizard, spock - game"""
import random
def instructions():
"""Displays menu and simple instructions on how to play"""
print("Welcome to rock, paper, scissor, lizard, spock!")
play = input("\nNavigate by \"yes\", \"no\", and numbers.\nNew game?:").lower()
if play == "yes":
print("1. Rock")
print("2. Paper")
print("3. Scissors")
print("4. Lizard")
print("5. Spock")
elif play != "no":
print("an error has occured. Please type \"yes\" or \"no\":")
instructions()
def get_user_choice():
"""Prompts the player to pick a 'weapon'"""
choice = int(input("What do you choose?: "))
if choice > 5:
print("Invalid number, please try again....")
get_user_choice()
elif choice < 1:
print("Invalid number, please try again....")
get_user_choice()
elif choice == 1:
print("You chose rock")
elif choice == 2:
print("You chose paper")
elif choice == 3:
print("You chose scissor")
elif choice == 4:
print("You chose lizard")
elif choice == 5:
print("You chose spock")
return choice
def get_pc_choice():
"""The computer chooses a random weapon"""
choice = random.randint(1, 5)
if choice == 1:
print("PC chose rock")
elif choice == 2:
print("PC chose paper")
elif choice == 3:
print("PC chose scissor")
elif choice == 4:
print("PC chose lizard")
elif choice == 5:
print("PC chose spock")
return choice
def winner(user_choice, pc_choice, user_wins, pc_wins, ties):
"""Calculates if the player or computer won the match"""
if user_choice == 1 and pc_choice == 3 or pc_choice == 4:
print("\nYou win.")
user_wins = user_wins.append(1)
elif user_choice == 2 and pc_choice == 1 or pc_choice == 5:
print("\nYou win.")
user_wins = user_wins.append(1)
elif user_choice == 3 and pc_choice == 2 or pc_choice == 4:
print("\nYou win.")
user_wins = user_wins.append(1)
elif user_choice == 4 and pc_choice == 2 or pc_choice == 5:
print("\nYou win.")
user_wins = user_wins.append(1)
elif user_choice == 5 and pc_choice == 1 or pc_choice == 3:
print("\nYou win.")
user_wins = user_wins.append(1)
elif user_choice == pc_choice:
print("\nTie")
ties = ties.append(1)
else:
print("\nPC won")
pc_wins = pc_wins.append(1)
return
def game_total(user_wins, pc_wins, ties):
"""Displays the total score"""
user_wins = sum(user_wins)
pc_wins = sum(pc_wins)
ties = sum(ties)
print("Your final score: ", user_wins)
print("PC\'s final Score: ", pc_wins)
print("Total ties: ", ties)
def main_one_p():
"""Main instructions for how the game runs"""
user_choice = 0
user_wins = []
pc_choice = 0
pc_wins = []
ties = []
final_user_wins = 0
final_pc_wins = 0
final_ties = 0
Continue = "yes"
instructions()
while Continue == "yes":
user_choice = get_user_choice()
pc_choice = get_pc_choice()
winner(user_choice, pc_choice, user_wins, pc_wins, ties)
Continue = input("Would you like to play again: ").lower()
if Continue == "no":
print("This is the final scores.")
break
game_total(user_wins, pc_wins, ties)
main_one_p()
player_one_rps()
game_menu() # Returns player to the main menu
(sorry if it is quite long)
Could anyone help point me in the direction of my mistake? Explanations and tips on how to fix it would also be greatly appreciated :)
In general, I'm thankful for all feedback, as i really want to become better at coding.
The global function must have a higher declarative code than where it is called. Simply reposition the function. The function game_menu must be below the function play_one_rps. The other functions are the same.
I am working on a rock, paper, scissors game for a programming homework assignment and I have run into a little snag. The program is suppose run by the user selecting 1 of 4 options, 1) rock, 2) paper, 3) scissors and 4) quit. Once the player selects an option the computers selection is displayed and the winner is announced and the program will ask if you would like to play another game. If y is select you go back to the main menu to choose another option, anything else will bring up the amount of games won, lost and how many games ended in a tie. If the player selects 4 the program should say "Exiting program..." and the game results should display.
Here are my issues:
Once you make the first selection, the winner is displayed and the program returns to main menu. If you make a second selection it will inform you of what the computer chose and then ask if you would like to play again. Y will take you back to the main menu, the computers selection will never change and no matter what you select the game will always end in the same result as the very first game. If you choose not to play again then the amount of games won, lost and tied will appear (this seems to be functioning correctly).
The quit option takes you back to the main menu instead of displaying the game results. I am not sure where to put that if statement.
Any help with these issues would be appreciated.
Thank you
#import module
import random
def main():
#create a variable to control the loop
play_again = 'y'
#create a counter for tied games, computer games and player games
tied_games = 0
computer_games = 0
player_games = 0
#display opening message
print("Let's play rock, paper scissors!")
computer_choice = process_computer_choice()
player_choice = process_player_choice()
winner = determine_winner(player_choice, computer_choice)
#setup while loop for playing multiple games
while play_again == 'y' or play_again == 'Y':
process_computer_choice()
process_player_choice()
#use a if else statement to print the computers choice
if computer_choice == 1:
print('computer chooses rock.')
elif computer_choice == 2:
print('computer chooses paper.')
else:
print('computer chooses scissors.')
#call the determine winner function
determine_winner(player_choice, computer_choice)
#check who won the game and add 1 to the correct counter
if winner == 'computer':
computer_games += 1
elif winner == 'player':
player_games += 1
else:
tied_games += 1
#ask the user if they would like to play again
play_again = input('would you like to play again? (enter y for yes): ')
#display number of games that were won by the computer, the player and that were tied
print()
print('there was', tied_games, 'tied games.')
print('the player won', player_games, 'games.')
print('The computer won', computer_games,'games.')
#define the process computer function
def process_computer_choice():
#setup computer to select random integer between 1 and 3
choice1 = random.randint(1, 3)
#return the computers choice
return choice1
#define the process player function
def process_player_choice():
#add input for players choice
print()
print(' MENU')
print('1) Rock!')
print('2) Paper!')
print('3) Scissors!')
print('4) Quit')
print()
player_choice = int(input('Please make a selection: '))
#add if statement for quit option
if player_choice == 4:
print('Exiting program....')
#validate if the user enters a correct selection
while player_choice != 1 and player_choice != 2 and player_choice != 3 and player_choice != 4:
#print a error message if the wrong selection is entered
print('Error! Please enter a correct selection.')
player_choice = int(input('Please make a selection: '))
#return the players choice
return player_choice
#define the determine winner function
def determine_winner(player_choice, computer_choice):
#setup if else statements for each of the 3 computer selections
if computer_choice == 1:
if player_choice == 2:
print('Paper wraps rock. You win!')
winner = 'player'
elif player_choice == 3:
print('Rock smashes scissors. The computer wins!')
winner = 'computer'
else:
print('The game is tied. Try again.')
winner = 'tied'
if computer_choice == 2:
if player_choice == 1:
print('Paper wraps rock. The computer wins!')
winner = 'computer'
elif player_choice == 3:
print('Scissors cut paper. You win!')
winner = 'player'
else:
print('The game is tied. Try again.')
winner = 'tied'
if computer_choice == 3:
if player_choice == 1:
print('Rock smashes scissors. You win!')
winner = 'player'
elif player_choice == 2:
print('Scissors cut paper. The computer wins!')
winner = 'computer'
else:
print('The game is tied. Try again.')
winner = 'tied'
return winner
main()
For issue 1, it's because you set the computer and player choices before your loop, and never update them. Change the beginning of your loop to:
while play_again == 'y' or play_again == 'Y':
computer_choice = process_computer_choice()
player_choice = process_player_choice()
You can also remove the lines of code before the loop that check the inputs and winner, as it's technically redundant for the first round.
For issue 2, just add the results after a 4 is chosen, like so:
if player_choice == 4:
print('Exiting program....')
print('there was', tied_games, 'tied games.')
print('the player won', player_games, 'games.')
print('The computer won', computer_games,'games.')
sys.exit() # be sure you add 'import sys' to the beginning of your file
Also, the line in your main loop determine_winner(player_choice, computer_choice) is indented so it will only be called if the computer chooses scissors, so you should unindent that :)
You aren't assigning to computer_choice or player_choice again, but using it's value.
while play_again == 'y' or play_again == 'Y':
process_computer_choice()
process_player_choice()
Should be
while play_again == 'y' or play_again == 'Y':
computer_choice = process_computer_choice()
player_choice = process_player_choice()
As for quitting just break in the quit choice. You have to return early from the process_player_choice and also do something in main.
So in process_player_choice:
if player_choice == 4:
print('Exiting program....')
return
and in main:
player_choice = process_player_choice()
if player_choice == 4:
return
winner = determine_winner(player_choice, computer_choice)
#setup while loop for playing multiple games
while play_again == 'y' or play_again == 'Y':
computer_choice = process_computer_choice()
player_choice = process_player_choice()
if player_choice == 4:
break
I am working on a rock paper scissors game. Everything seems to be working well except the win/loss/tie counter. I have looked at some of the other games people have posted on here and I still cannot get mine to work. I feel like I am soooooo close but I just can't get it! thanks for any help guys. this is my first time posting in here so I am sorry if I messed up the formatting.
I edited the code but still cannot get the program to recognize the counter without using global variables. at one point of my editing I managed to get it to count everything as a tie... i dont know how and I lost it somewhere along my editing. lol. -thanks again everyone!
here is what I get when I run the program:
Prepare to battle in a game of paper, rock, scissors!
Please input the correct number according
to the object you want to choose.
Select rock(1), paper(2), or scissors(3): 1
Computer chose PAPER .
You chose ROCK .
You lose!
Play again? Enter 'y' for yes or 'n' for no. y
Prepare to battle in a game of paper, rock, scissors!
Please input the correct number according
to the object you want to choose.
Select rock(1), paper(2), or scissors(3): 2
Computer chose PAPER .
You chose PAPER .
It's a tie!
Play again? Enter 'y' for yes or 'n' for no. y
Prepare to battle in a game of paper, rock, scissors!
Please input the correct number according
to the object you want to choose.
Select rock(1), paper(2), or scissors(3): 3
Computer chose SCISSORS .
You chose SCISSORS .
It's a tie!
Play again? Enter 'y' for yes or 'n' for no. n
Your total wins are 0 .
Your total losses are 0 .
Your total ties are 0 .
#import the library function "random" so that you can use it for computer
#choice
import random
#define main
def main():
#assign win, lose, and tie to zero for tallying
win = 0
lose = 0
tie = 0
#control loop with 'y' variable
play_again = 'y'
#start the game
while play_again == 'y':
#make a welcome message and give directions
print('Prepare to battle in a game of paper, rock, scissors!')
print('Please input the correct number according')
print('to the object you want to choose.')
#Get the player and computers choices and
#assign them to variables
computer_choice = get_computer_choice()
player_choice = get_player_choice()
#print choices
print('Computer chose', computer_choice, '.')
print('You chose', player_choice, '.')
#determine who won
winner_result(computer_choice, player_choice)
#ask the user if they want to play again
play_again = input("Play again? Enter 'y' for yes or 'n' for no. ")
#print results
print('Your total wins are', win, '.')
print('Your total losses are', lose, '.')
print('Your total ties are', tie, '.')
#define computer choice
def get_computer_choice():
#use imported random function from library
choice = random.randint(1,3)
#assign what the computer chose to rock, paper, or scissors
if choice == 1:
choice = 'ROCK'
elif choice == 2:
choice = 'PAPER'
else:
choice = 'SCISSORS'
#return value
return choice
#define player choice
def get_player_choice():
#assign input to variable by prompting user
choice = int(input("Select rock(1), paper(2), or scissors(3): "))
#Detect invalid entry
while choice != 1 and choice != 2 and choice != 3:
print('The valid numbers are rock(type in 1), paper(type in 2),')
print('or scissors(type in 3).')
choice = int(input('Enter a valid number please: '))
#assign what the player chose based on entry
if choice == 1:
choice = 'ROCK'
elif choice == 2:
choice = 'PAPER'
else:
choice = 'SCISSORS'
#return value
return choice
#determine the winner from the variables
def winner_result(computer_choice, player_choice):
#if its a tie, add 1 to tie variable and display message
if computer_choice == player_choice:
result = 'tie'
print("It's a tie!")
#if its a win, add to win tally and display message
elif computer_choice == 'SCISSORS' and player_choice == 'ROCK':
result = 'win'
print('ROCK crushes SCISSORS! You win!')
elif computer_choice == 'PAPER' and player_choice == 'SCISSORS':
result = 'win'
print('SCISSORS cut PAPER! You win!')
elif computer_choice == 'ROCK' and player_choice == 'PAPER':
result = 'win'
print('PAPER covers ROCK! You win!')
#if it does not match any of the win criteria then add 1 to lose and
#display lose message
else:
result = 'lose'
print('You lose!')
def result(winner_result,player_choice, computer_choice):
# accumulate the appropriate winner of game total
if result == 'win':
win += 1
elif result == 'lose':
lose += 1
else:
tie += 1
return result
main()
Your winner_result function returns before it increments the win counters. If you remove all the return statements from it, the counters should be updated. The return statements aren't needed anyway because the if/elif/else structure ensures that only one of the possible outcomes will be executed.
As Junuxx says in a comment, you also need to assign values to the winner_result variable properly, i.e. winner_result = 'win' instead of winner_result == 'win'. I'd also rename the winner_result variable or the function, because it's confusing to have both use the same name.
And the win/lose/tie variables are currently local, which means that main and winner_result will have their own copies of these variables, so main's values will always be zero. What you can do is make them global variables: Assign them to zero in the global scope (outside any function), and add the line global win, lose, tie inside the function winner_result.
Obviously been a few years since this question was answered but it came up while I was looking the same info. Here's my code if anyone is interested.
#! usr/bin/python3
import random
def game():
computer_count = 0
user_count = 0
while True:
base_choice = ['scissors', 'paper', 'rock']
computer_choice = random.choice(base_choice)
user_choice = input('(scissors, paper, rock) Type your choice: ').strip().lower()
print()
computer_wins = 'The computer wins!'
you_win = 'You win!'
print(f'You played {user_choice}, the computer played {computer_choice}')
if user_choice == 'scissors' and computer_choice == 'rock' or \
user_choice == 'paper' and computer_choice == 'scissors' or \
user_choice == 'rock' and computer_choice == 'paper':
print(computer_wins)
computer_count += 1
elif user_choice == 'rock' and computer_choice == 'scissors' or \
user_choice == 'scissors' and computer_choice == 'paper' or \
user_choice == 'paper' and computer_choice == 'rock':
print(you_win)
user_count += 1
else:
if user_choice == computer_choice:
print('Its a draw!')
computer_count += 1
user_count += 1
print(f'Computer: {computer_count} - You: {user_count}')
print()
game()
I was trying to do the same project, and I have found a solution that works well for me.
from random import randint
win_count = 0
lose_count = 0
tie_count = 0
# create a list of play options
t = ["Rock", "Paper", "Scissors"]
# assign a random play to the computer
computer = t[randint(0, 2)]
# set player to false
player = False
print()
print("To stop playing type stop at any time.")
print()
while player == False:
# set player to True
player = input("Rock, Paper or Scissors? ")
if player.lower() == "stop":
print()
print(
f"Thanks for playing! Your final record was {win_count}-{lose_count}-{tie_count}")
print()
break
if player.title() == computer:
print()
print("Tie!")
tie_count += 1
print()
elif player.title() == "Rock":
if computer == "Paper":
print()
print(f"You lose. {computer} covers {player.title()}.")
lose_count += 1
print()
else:
print()
print(f"You win! {player.title()} smashes {computer}.")
win_count += 1
print()
elif player.title() == "Paper":
if computer == "Scissors":
print()
print(f"You lose. {computer} cuts {player.title()}.")
lose_count += 1
print()
else:
print()
print(f"You win!, {player.title()} covers {computer}.")
win_count += 1
print()
elif player.title() == ("Scissors"):
if computer == "Rock":
print()
print(f"You lose. {computer} smashes {player.title()}.")
lose_count += 1
print()
else:
print()
print(f"You win! {player.title()} cuts {computer}.")
win_count += 1
print()
else:
print()
print("Sorry, we couldn't understand that.")
print()
# player was set to True, but we want it to be false to continue loop
print(f"Your record is {win_count}-{lose_count}-{tie_count}")
print()
player = False
computer = t[randint(0, 2)]
This works (kinda)
there are many issues with the code at the top of the page.
Firstly, Scoring doesn't work.
Secondly, nothing is indented meaning that nothing inside of the other def functions will work.
Thirdly, The other def functions are referred to in the first def main statement which causes Python to show an invalid syntax due to Python not knowing the other functions as they were referred to before they were introduced to python.