Adding a Play Again functionality (Basic Python) [duplicate] - python

I have made a rock, paper, scissors game in python. How would I get the game to repeat over if the user enters yes? My code appears to go into a never ending loop when the user enters anything but rock, paper, or scissors
Also I'm trying to learn when and where I should use functions. If you could show a pythonic way to separate the finished code into functions I would greatly appreciate that.
import random
a = ["rock", "paper", "scissors"]
word = input('Enter rock, paper, or scissors: ')
def game():
while True:
try:
if word not in a:
raise ValueError #this will send it to the print message and back to the input option
break
except ValueError:
print(" You must enter rock, paper, or scissors.")
comp_draw = random.choice(a)
print('The computer drew ' + comp_draw)
if comp_draw == 'rock' and word=='rock':
print('It was a tie')
elif comp_draw == 'paper' and word=='paper':
print('It was a tie')
elif comp_draw == 'scissors' and word=='scissors':
print('It was a tie')
elif comp_draw == 'paper' and word=='rock':
print('you lost')
elif comp_draw == 'rock' and word=='paper':
print('you won!')
elif comp_draw == 'rock' and word=='scissors':
print('you lost')
elif comp_draw == 'scissors' and word=='rock':
print('you won!')
elif comp_draw == 'scissors' and word=='rock':
print('you won!')
elif comp_draw == 'scissors' and word=='rock':
print('you won!')
game()
play_again = input('would you like to play again: ')

Wasn't missing much, all you needed was a loop
import random
a = ["rock", "paper", "scissors"]
word = input('Enter rock, paper, or scissors: ')
def game():
while True:
try:
if word not in a:
raise ValueError #this will send it to the print message and back to the input option
break
except ValueError:
print(" You must enter rock, paper, or scissors.")
comp_draw = random.choice(a)
print('The computer drew ' + comp_draw)
if comp_draw == 'rock' and word=='rock':
print('It was a tie')
elif comp_draw == 'paper' and word=='paper':
print('It was a tie')
elif comp_draw == 'scissors' and word=='scissors':
print('It was a tie')
elif comp_draw == 'paper' and word=='rock':
print('you lost')
elif comp_draw == 'rock' and word=='paper':
print('you won!')
elif comp_draw == 'rock' and word=='scissors':
print('you lost')
elif comp_draw == 'scissors' and word=='rock':
print('you won!')
elif comp_draw == 'scissors' and word=='rock':
print('you won!')
elif comp_draw == 'scissors' and word=='rock':
print('you won!')
play_again = "yes"
while play_again == "yes":
game()
play_again = input('would you like to play again: ').lower()

Instead of :
game()
play_again = input("...")
Put your game in a loop as follow :
while True:
play_again = input ("would you like to play")
if play_again == "yes" :
game()
continue
elif play_again == "no" :
break
else:
print("answer by yes or no")
continue

There was also an issue of the variable word being outside the scope of game(). It would work on the first run but not the consequent runs thereafter. This code seems to work fine and as expected.
import random
a = ["rock", "paper", "scissors"]
def game():
while True:
try:
word = input('Enter rock, paper, or scissors: ')
if word not in a:
raise ValueError # this will send it to the print message and back to the input option
break
except ValueError:
print(" You must enter rock, paper, or scissors.")
comp_draw = random.choice(a)
print('The computer drew ' + comp_draw)
if comp_draw == 'rock' and word =='rock':
print('It was a tie')
elif comp_draw == 'paper' and word =='paper':
print('It was a tie')
elif comp_draw == 'scissors' and word =='scissors':
print('It was a tie')
elif comp_draw == 'paper' and word =='rock':
print('you lost')
elif comp_draw == 'rock' and word =='paper':
print('you won!')
elif comp_draw == 'rock' and word =='scissors':
print('you lost')
elif comp_draw == 'scissors' and word =='rock':
print('you won!')
elif comp_draw == 'scissors' and word =='rock':
print('you won!')
elif comp_draw == 'scissors' and word =='rock':
print('you won!')
if __name__ == "__main__":
game()
while True:
if input('Would you like to play_again? ') == 'yes':
game()
else:
break

Related

Rock Paper and Scissors in Python

I'm new to coding and my Rock Paper and Scissors game that i've created isn't working as intended.
If someone enters the word rock, paper or scissors, then the programme works as intended.
However, when the someone enters a word other than rock, paper or scissors the programme should say "I don't understand, please try again" and prompt the user to enter another input, which it does, but then instead of continuing and working as intended the programme ends. Here is the code:
# The game of Rock Paper Scissors
import random
choices = ['rock', 'paper', 'scissors']
computer_choice = random.choice(choices)
selections = 'The computer chose ' + computer_choice + ' so'
computer_score = 0
user_score = 0
def choose_option():
user_choice = input('Please choose Rock, Paper or Scissors. (q to quit)\n>>> ')
while user_choice != 'q':
if user_choice in ['ROCK', 'Rock', 'rock', 'R', 'r']:
user_choice = 'rock'
elif user_choice in ['PAPER', 'Paper', 'paper', 'P', 'p']:
user_choice = 'paper'
elif user_choice in ['SCISSORS','Scissors', 'scissors', 'S', 's']:
user_choice = 'scissors'
else:
print("I don't understand, please try again.")
choose_option()
return user_choice
user_choice = choose_option()
while user_choice != 'q':
if user_choice == computer_choice:
print(selections + ' it\'s a tie')
elif (user_choice == 'rock' and computer_choice == 'scissors'):
user_score += 1
print(selections + ' you won! :)')
elif (user_choice == 'paper' and computer_choice == 'rock'):
user_score += 1
print(selections + ' you won! :)')
elif (user_choice == 'scissors' and computer_choice == 'paper'):
user_score += 1
print(selections + ' you won! :)')
elif (user_choice == 'rock' and computer_choice == 'paper'):
computer_score += 1
print(selections + ' you lost :(')
elif (user_choice == 'paper' and computer_choice == 'scissors'):
computer_score += 1
print(selections + ' you lost :(')
elif (user_choice == 'scissors' and computer_choice == 'rock'):
computer_score += 1
print(selections + ' you lost :(')
else:
break
print('You: ' + str(user_score) + " VS " + "Computer: " + str(computer_score))
computer_choice = random.choice(choices)
selections = 'The computer chose ' + computer_choice + ' so'
user_choice = choose_option()
Your problem seemed to be caused by calling the function inside the function. This solved it for me:
def choose_option():
user_choice = input('Please choose Rock, Paper or Scissors. (q to quit)\n>>> ')
while user_choice != 'q':
if user_choice in ['ROCK', 'Rock', 'rock', 'R', 'r']:
user_choice = 'rock'
return user_choice
elif user_choice in ['PAPER', 'Paper', 'paper', 'P', 'p']:
return user_choice
elif user_choice in ['SCISSORS','Scissors', 'scissors', 'S', 's']:
return user_choice
else:
while user_choice.lower() not in ["rock", "paper", "scissors", "s","r","p","q"]:
print("I don't understand, please try again.")
user_choice = input('Please choose Rock, Paper or Scissors. (q to quit)\n>>> ')
This way, if the computer does not like the input it can just request another one.
Also I would recommend using
if user_choice.lower() in [], just a little easier than typing in all the options.
Hope this helps!
instead of
else:
print("I don't understand, please try again.")
choose_option()
you can use
while user_choice != 'q':
user_choice = input('Please choose Rock, Paper or Scissors. (q to quit)\n>>> ')
if user_choice in ['ROCK', 'Rock', 'rock', 'R', 'r']:
user_choice = 'rock'
elif user_choice in ['PAPER', 'Paper', 'paper', 'P', 'p']:
user_choice = 'paper'
elif user_choice in ['SCISSORS','Scissors', 'scissors', 'S', 's']:
user_choice = 'scissors'
else:
print("I don't understand, please try again.")
continue
return user_choice
continue will cause the program to skip the rest of the loop (here, skipping the return) and continuing with the next iteration of the while loop (going back up to user_choice = ...). Also note that I think there's another bug where if user_choice is "q", the result is not actually returned.

When running this code, why does the loop not wait for my response?

import random
def rock_paper_scissors(choice):
computer_choice = random.choice(['rock', 'paper', 'scissors'])
while True:
if choice == computer_choice:
print("Tie! Play again.")
choice
elif choice.lower() == 'quit':
break
elif choice.lower() == 'rock' and computer_choice.lower() == 'paper':
print("TRY AGAIN!", computer_choice.lower(), "beats", choice.lower())
choice
elif choice.lower() == 'rock' and computer_choice.lower() == 'scissors':
print("YOU WON!", choice.lower(), "beats", computer_choice.lower())
choice
elif choice.lower() == 'paper' and computer_choice.lower() == 'scissors':
print("TRY AGAIN!", computer_choice.lower(), "beats", choice.lower())
choice
elif choice.lower() == 'paper' and computer_choice.lower() == 'rock':
print("YOU WON!", choice.lower(), "beats", computer_choice.lower())
choice
elif choice.lower() == 'scissors' and computer_choice.lower() == "rock":
print("TRY AGAIN!", computer_choice.lower(), "beats", choice.lower())
choice
elif choice.lower() == 'scissors' and computer_choice.lower() == "paper":
print("YOU WON!", choice.lower(), 'beats', computer_choice.lower())
choice
else:
print("Sorry, invalid.")
choice
print(rock_paper_scissors(input("Rock paper or scissors (enter 'q' to quit): ")))
When this code is run, whatever is in the print in the elif is repeated over and over and over again in the run box. I don't know if I should fix the while statement or add additional code in the elif statements. The input works fine, but I don't know what to add to the while loop. (I am a beginner Python programmer)
The input statement is not in the scope of the while loop, so it is only called once.
Once in the while loop, there is nothing changing the choice variable and hence the same print statement get triggered over and over.
Moving the input statement into the while loop along with the the computer choice initialisation (so the computer can choose a new option each go) solves your problem.
import random
def rock_paper_scissors():
while True:
computer_choice = random.choice(['rock', 'paper', 'scissors'])
choice = input("Rock paper or scissors (enter 'q' to quit): ")
if choice == computer_choice:
print("Tie! Play again.")
elif choice.lower() == 'quit':
break
elif choice.lower() == 'rock' and computer_choice.lower() == 'paper':
print("TRY AGAIN!", computer_choice.lower(), "beats", choice.lower())
elif choice.lower() == 'rock' and computer_choice.lower() == 'scissors':
print("YOU WON!", choice.lower(), "beats", computer_choice.lower())
elif choice.lower() == 'paper' and computer_choice.lower() == 'scissors':
print("TRY AGAIN!", computer_choice.lower(), "beats", choice.lower())
elif choice.lower() == 'paper' and computer_choice.lower() == 'rock':
print("YOU WON!", choice.lower(), "beats", computer_choice.lower())
elif choice.lower() == 'scissors' and computer_choice.lower() == "rock":
print("TRY AGAIN!", computer_choice.lower(), "beats", choice.lower())
elif choice.lower() == 'scissors' and computer_choice.lower() == "paper":
print("YOU WON!", choice.lower(), 'beats', computer_choice.lower())
else:
print("Sorry, invalid.")
rock_paper_scissors()
I thought I'd share an alternative way of writing this that may be of help to a beginner. The goals are:
To reduce repetition, so you only have one print("You Lose") rather than three.
To separate the winning logic into a separate function, which makes it easier to test the logic part and allows code reuse.
import random
def did_player_win(computer, player):
# Returns None for a tie, True for a win, False for a lose
if computer == player:
return None
if computer == 'paper':
return False if player == 'rock' else True
if computer == 'scissors':
return False if player == 'paper' else True
if computer == 'rock':
return False if player == 'scissors' else True
def play():
while True:
player = input("Rock, paper or scissors (enter 'q' to quit): ")
player = player.lower()
if player not in ['rock', 'paper', 'scissors']:
break
computer = random.choice(['rock', 'paper', 'scissors'])
player_won = did_player_win(computer, player)
if player_won is True:
print("YOU WON! {0} beats {1}".format(player, computer))
elif player_won is False:
print("TRY AGAIN! {0} beats {1}".format(computer, player))
else:
print("Tie! Both chose {0}".format(player))
play()

rock paper scissor python program input error

import random
def rpc():
a = ["rock", "paper", "scissor"]
b = random.choice(a)
print(b)
userinput = input('please type rock, paper or scissor:')
if userinput == "":
print("please print the right thing")
rpc()
if userinput != "rock":
print("type the right thing!")
rpc()
if userinput != "paper":
print("type the right thing!")
rpc()
if userinput != "scissor":
print("type the right thing!")
rpc()
while b == userinput:
print("it is a draw, do you want to play another one?")
c = input("type 'y' if you want to play one more time or press 'n': ")
if c == 'y':
rpc()
elif c =='n':
break
else:
print("print the right words please")
if b == 'rock' and userinput == 'paper':
print("you win!")
rpc()
elif b == 'rock' and userinput == 'scissor':
print("you lost")
rpc()
elif b == 'paper' and userinput == 'scissor':
print("you win!")
rpc()
elif b == 'paper' and userinput == 'rock':
print("you lost!")
rpc()
elif b == 'scissor' and userinput == 'rock':
print("you win!")
rpc()
elif b == 'scissor' and userinput == 'paper':
print("you lost!")
rpc()
rpc()
This is my code for rock paper and scissor, it's pretty simple but when I run my code and input my rock, paper and scissor, I get my please print the right thing statement, O have no idea why it's happening, any help would be wonderful, thank you!
Lets clean this up....
userinput = input('please type rock, paper or scissor:')
while userinput not in acceptable_inputs:
userinput = input('please type rock, paper or scissor:')
opponents_choice = random.choice(objects)
# Check and print. Loop to keep playing - 2 out of 3 wins....
import random
def winner(riya,siya):
if (riya==siya):
return None
elif (riya=="s"):
if (siya=="p"):
return False
elif(siya=="k"):
return True
elif (riya=="p"):
if (siya=="s"):
return False
elif (siya=="k"):
return True
elif (riya=="k"):
if (siya=="s"):
return True
elif (siya=="p"):
return False
print("riya pick: stone(s) paper(p) sessior(k)")
a= random.randint(1,3)
if a==1:
riya="s"
elif a==2:
riya="p"
elif a==3:
riya="k"
siya=input(" siya pick: stone(s) paper(p) sessior(k)")
b=winner(riya,siya)
print(f"riya pick{riya}")
print(f"siya pick {siya}")
if b==None:
print("tie")
elif b:
print("winner")`enter code here`
else:enter code here
print("loose")

How to create a Rock, Paper, Scissors program

I'm very new to python and am taking an online class. I'm not very familiar with many functions in python so if you could keep it somewhat basic for me to keep track of, I would really appreciate it. I am trying to make a program that runs Rock, Paper, Scissors with a user but the num_games is not being accepted in the "for i in range". Also, I have run it and found that Scissors can beat Rock (THIS IS ANARCHY!). Can anyone assist me? Thanks in advance!
import random
def comp_turn():
comp_move = random.randint(1,3)
if comp_move == 1:
return "Rock!"
elif comp_move == 2:
return "Paper!"
else:
return "Scissors!"
def main():
num_games = int(input("Enter how many games you would like to play: "))
print "You are going to play " + str(num_games) + " games! Here we go!"
num_wins = 0
for i in range(num_games):
user_move = input("Choose either Rock, Paper or Scissors and enter it: ")
cpu_turn = comp_turn()
print "The computer went with: " + cpu_turn
if user_move == 'Rock' and cpu_turn == 'Scissors':
print "You won! Nice job!"
num_wins +=1
elif user_move == 'Paper' and cpu_turn == 'Rock':
print "You won! Nice job!"
num_wins +=1
elif user_move == 'Scissors' and cpu_turn == 'Paper':
print "You won! Nice job!"
num_wins +=1
elif user_move == cpu_turn:
print "Oh! You tied"
else:
print "Whoops! You lost!"
return num_wins
print main()
This should be what you want:
import random
def comp_turn():
return random.choice(['Rock','Paper','Scissors'])
def main():
num_games = int(input("Enter how many games you would like to play: "))
print("You are going to play " + str(num_games) + " games! Here we go!")
num_wins = 0
for i in range(num_games):
user_move = input("Choose either Rock, Paper or Scissors and enter it: ")
cpu_turn = comp_turn()
print("The computer went with: " + cpu_turn)
if user_move == 'Rock' and cpu_turn == 'Scissors': print("You won! Nice job!"); num_wins +=1
elif user_move == 'Paper' and cpu_turn == 'Rock': print("You won! Nice job!"); num_wins +=1
elif user_move == 'Scissors' and cpu_turn == 'Paper': print("You won! Nice job!"); num_wins +=1
elif user_move == cpu_turn: print("Oh! You tied")
else: print("Whoops! You lost!");
return num_wins
print(main())
Or even Better:
import random
def comp_turn():
return random.choice(['Rock','Paper','Scissors'])
def main():
num_games = int(input("Enter how many games you would like to play: "))
print("You are going to play " + str(num_games) + " games! Here we go!")
num_wins = 0
winning=[('Rock','Scissors'),('Paper','Rock'),('Scissors','Paper')]
for i in range(num_games):
user_move = input("Choose either Rock, Paper or Scissors and enter it: ")
cpu_turn = comp_turn()
print("The computer went with: " + cpu_turn)
if (user_move,cpu_turn) in winning:
print('You won!')
num_wins+=1
elif user_move == cpu_turn:
print('Same')
else:
print('You lost!')
return num_wins
print(main())
And another option that's also good:
import random
def comp_turn():
return random.choice(['Rock','Paper','Scissors'])
def main():
num_games = int(input("Enter how many games you would like to play: "))
print("You are going to play " + str(num_games) + " games! Here we go!")
num_wins = 0
d={}.fromkeys([('Rock','Scissors'),('Paper','Rock'),('Scissors','Paper')],'You Won')
for i in range(num_games):
user_move = input("Choose either Rock, Paper or Scissors and enter it: ")
cpu_turn = comp_turn()
print("The computer went with: " + cpu_turn)
if not user_move == cpu_turn:
print(d.get((user_move,cpu_turn),'You lost!'))
else:
print('Same')
return num_wins
print(main())
Here's what you want:
import random
outcome = random.choice(['Rock', 'Paper', 'Scissors'])
print(outcome)
Have you tried removing the '!' in the comp_turn function? It seems like cpu_turn variable will contain either 'Rock!', 'Scissors!' or 'Paper!' while your if-else condition is looking for either 'Rock', 'Scissors' or 'Paper' without the '!'. So, no matter what the player or cpu chooses, it will go into 'else' in the 'for' loop and the player loses.
This is the edited code:
import random
def comp_turn():
comp_move = random.randint(1,3)
if comp_move == 1: return "Rock"
elif comp_move == 2: return "Paper"
else: return "Scissors"
def main():
num_games = int(input("Enter how many games you would like to play: "))
print("You are going to play " + str(num_games) + " games! Here we go!")
num_wins = 0
for i in range(num_games):
user_move = input("Choose either Rock, Paper or Scissors and enter it: ")
cpu_turn = comp_turn()
print("The computer went with: " + cpu_turn)
if user_move == 'Rock' and cpu_turn == 'Scissors':
print("You won! Nice job!")
num_wins +=1
elif user_move == 'Paper' and cpu_turn == 'Rock':
print("You won! Nice job!")
num_wins +=1
elif user_move == 'Scissors' and cpu_turn == 'Paper':
print("You won! Nice job!")
num_wins +=1
elif user_move == cpu_turn:
print("Oh! You tied")
else: print("Whoops! You lost!")
return num_wins
print(main())
Do note that the player's input is case sensitive too. Hope this helps!

Python Newbie - Rock, Paper, Scissors

I'm very new to Python and decided to set myself a challenge of programming a Rock, Paper, Scissors game without copying someone else's code. However, I need help from a Pythonista grown-up!
I've seen many other variations on Rock, Paper, Scissors, on here but nothing to explain why my version isn't working. My program basically follows this format: set empty variables at start, define 4 functions that prints intro text, receives player input, randomly picks the computer's choice, then assesses whether its a win or a loss for the player.
This is all then stuck in a while loop that breaks once the player selects that they don't want to play anymore. (This bit is working fine)
However, whenever I run the code, it just always gives a draw and doesn't seem to store any data for the computer's choice function call. Does anybody know what I'm doing wrong?
Many thanks!
import random
playerAnswer = ''
computerAnswer = ''
winsTotal = 0
timesPlayed = 0
def showIntroText():
print('Time to play Rock, Paper, Scissors.')
print('Type in your choice below:')
def playerChoose():
playerInput = input()
return
def computerChoose():
randomNumber = random.randint(1, 3)
if randomNumber == 1:
computerPick = 'Paper'
elif randomNumber == 2:
computerPick = 'Scissors'
else:
computerPick = 'Rock'
return
def assessResult():
if playerAnswer == computerAnswer:
print('Draw!')
elif playerAnswer == 'Rock' and computerAnswer == 'Paper':
print('Paper beats Rock. You lose!')
elif playerAnswer == 'Paper' and computerAnswer == 'Scissors':
print('Scissors cuts Paper. You lose!')
elif playerAnswer == 'Scissors' and computerAnswer == 'Rock':
print('Rock blunts Scissors. You lose!')
else:
print('You win!')
winsTotal += 1
return
while True:
timesPlayed += 1
showIntroText()
playerAnswer = playerChoose()
computerAnswer = computerChoose()
assessResult()
print('Do you want to play again? (y/n)')
playAgain = input()
if playAgain == 'n':
break
print('Thank you for playing! You played ' + str(timesPlayed) + ' games.')
You have missed returning values in most of the case.
** Add 'return playerInput ' in playerChoose() instead of only return.
** Add ' return computerPick ' in computerChoose() instead of return.
** Initialize winsTotal variable before using it as 'winsTotal = 0' in assessResult().
** Variables you have intialized at the start of program are out of scope for functions.
Please check this StackOverFlow link for understanding scope of variables in python.
** Add 'return winsTotal' in assessResult() instead of return.
import random
def showIntroText():
print('Time to play Rock, Paper, Scissors.')
print('Type in your choice below:')
def playerChoose():
playerInput = input()
return playerInput
def computerChoose():
randomNumber = random.randint(1, 3)
if randomNumber == 1:
computerPick = 'Paper'
elif randomNumber == 2:
computerPick = 'Scissors'
else:
computerPick = 'Rock'
return computerPick
def assessResult(winsTotal):
if playerAnswer == computerAnswer:
print('Draw!')
elif playerAnswer == 'Rock' and computerAnswer == 'Paper':
print('Paper beats Rock. You lose!')
elif playerAnswer == 'Paper' and computerAnswer == 'Scissors':
print('Scissors cuts Paper. You lose!')
elif playerAnswer == 'Scissors' and computerAnswer == 'Rock':
print('Rock blunts Scissors. You lose!')
else:
print('You win!')
winsTotal += 1
return winsTotal
total_win = 0
while True:
timesPlayed += 1
showIntroText()
playerAnswer = playerChoose()
computerAnswer = computerChoose()
total_win = assessResult(total_win)
print('Do you want to play again? (y/n)')
playAgain = input()
if playAgain == 'n':
break
print('Thank you for playing! You played ' + str(timesPlayed) + ' games.' + 'Out of which you won '+ str(total_win))
Output:
C:\Users\dinesh_pundkar\Desktop>python c.py
Time to play Rock, Paper, Scissors.
Type in your choice below:
"Rock"
You win!
Do you want to play again? (y/n)
"y"
Time to play Rock, Paper, Scissors.
Type in your choice below:
"Rock"
Draw!
Do you want to play again? (y/n)
"y"
Time to play Rock, Paper, Scissors.
Type in your choice below:
"Rock"
Paper beats Rock. You lose!
Do you want to play again? (y/n)
"y"
Time to play Rock, Paper, Scissors.
Type in your choice below:
"Rock"
Paper beats Rock. You lose!
Do you want to play again? (y/n)
"n"
Thank you for playing! You played 4 games.Out of which you won 1
add input and return in your functions
def computerChoose And def assessResultreturn None
for Example by this code you can play this game :
import random
playerAnswer = ''
computerAnswer = ''
winsTotal = 0
timesPlayed = 0
def playerChoose():
playerInput = input("insert:")
return playerInput
def computerChoose():
randomNumber = random.randint(1, 3)
if randomNumber == 1:
computerPick = 'Paper'
elif randomNumber == 2:
computerPick = 'Scissors'
else:
computerPick = 'Rock'
return computerPick
def assessResult(playerAnswer, computerAnswer):
if playerAnswer == computerAnswer:
print('Draw!')
elif playerAnswer == 'Rock' and computerAnswer == 'Paper':
print('Paper beats Rock. You lose!')
elif playerAnswer == 'Paper' and computerAnswer == 'Scissors':
print('Scissors cuts Paper. You lose!')
elif playerAnswer == 'Scissors' and computerAnswer == 'Rock':
print('Rock blunts Scissors. You lose!')
else:
print('You win!')
return
while True:
timesPlayed += 1
playerAnswer = playerChoose()
computerAnswer = computerChoose()
assessResult(playerAnswer,computerAnswer)
print('Do you want to play again? (y/n)')
playAgain = input()
if playAgain == 'n':
break
print('Thank you for playing! You played ' + str(timesPlayed) + ' games.')
It is always a draw because you aren't returning the answers from your function, both playerAnswer and computerAnswer return None
As some of people said playerChoose() and computerChoose() return with None
Modifidy these statement playerChoose() -> return playerInput
and computerChoose() -> return computerPick
AS well as you have to use global variable. Insert this row
global winsTotal
in the assessResult().

Categories