Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8669615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:31:08+00:00 2026-06-12T18:31:08+00:00

I’m making a rock, paper scissors game as a little project while I’m starting

  • 0

I’m making a rock, paper scissors game as a little project while I’m starting out and I have to use the same bit of code a lot. What’s the best way to do this because at the moment I have it copied and pasted all over the place. It looks untidy plus I’m having an issue with the looping while validating the input and it’s a pain to have to change it all.

user_continue = raw_input("Would you like to play again? Y/N: ")
user_continue = user_continue.upper()
#Yes or no continue for the continue while loop to continue working until correct user input.
y_n_continue = False
while y_n_continue == False:
    if user_continue == "Y" or user_continue == "YES" or user_continue == "N" or user_continue == "NO":
        if user_continue == "Y" or user_continue == "YES":
            continue_game = True
            y_n_continue = True
        elif user_continue == "N" or user_continue == "NO":
            continue_game = False
            y_n_continue = True
        else:
            print "Press Y or N"
            y_n_continue = False
    else:
        print ""

It would probably be easier if I added the whole code (With the fix, thanks to Anton.
At the moment I am getting the error – TypeError: ‘bool’ object is not callable.

I’m basically trying to get it to loop the game for as long as the user wants while also validating the inputs to make everything as bulletproof as possible.

EDIT 2 – Here is the new code and I have some test data under it.

When I launch it you are prompted to enter y/n at the start.

You also have to enter y or n twice after each game.

If you input ‘wrong’ data into the rock/paper/scissors selection it goes to the y/n selection

import random


def continue_game():
    while True:
        user_continue = raw_input("Would you like to play again? Y/N: ").upper()
        if user_continue in ["Y", "YES", "N", "NO"]:
            return user_continue in ["Y", "YES"]
        else:
            print "Press Y or N"



while continue_game():

    #computers choice of rock, paper or scissors
    computer_input = ["ROCK", "PAPER", "SCISSORS"]
    computer_choice = random.choice(computer_input)
    #users choice or rock, paper or scissors
    user_input = raw_input("Choose rock, paper or scissors: ")
    #Turns user input to upper case.
    user_choice = user_input.upper()
    if user_choice == "ROCK" or user_choice == "PAPER" or user_choice == "SCISSORS":
        #Computer = ROCK
        if computer_choice == "ROCK":
            #user = ROCK
            if user_choice == "ROCK":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You draw!"

                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False



            #user = PAPER
            elif user_choice == "PAPER":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You win!"
                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False


            #user = SCISSORS   
            elif user_choice == "SCISSORS":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You lose!"
                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False


        #Computer = PAPER
        elif computer_choice == "PAPER":
            #user = ROCK
            if user_choice == "ROCK":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You lose!"
                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False

            #user = PAPER
            elif user_choice == "PAPER":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You draw!"
                if continue_game():
                    print "continue"
                else:
                    continue_game = False


            #user = SCISSORS   
            elif user_choice == "SCISSORS":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You win!"
                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False

        #Computer = SCISSORS
        elif computer_choice == "SCISSORS":
            #user = ROCK
            if user_choice == "ROCK":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You win!"
                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False

            #user = PAPER
            elif user_choice == "PAPER":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You lose!"
                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False

            #user = SCISSORS   
            elif user_choice == "SCISSORS":
                print "You have chosen: " + user_choice
                print "The computer has chosen: " + computer_choice
                print "You draw!"
                #replay?
                if continue_game():
                    print "continue"
                else:
                    continue_game = False

        else:
            print "Something has gone wrong."
    else:
        print "Are you sure you entered that correctly?"

Output:

Would you like to play again? Y/N: y

Choose rock, paper or scissors: rock

You have chosen: ROCK

The computer has chosen: PAPER

You lose!

Would you like to play again? Y/N: y

continue

Would you like to play again? Y/N: y

Choose rock, paper or scissors: paper

You have chosen: PAPER

The computer has chosen: ROCK

You win!

Would you like to play again? Y/N: wer

Press Y or N

Would you like to play again? Y/N: dfg

Press Y or N

Would you like to play again? Y/N: y

continue

Would you like to play again? Y/N: y

Choose rock, paper or scissors: test

Are you sure you entered that correctly?

Would you like to play again? Y/N: y

Choose rock, paper or scissors: rock

You have chosen: ROCK

The computer has chosen: SCISSORS

You win!

Would you like to play again? Y/N: n

exit

Would you like to play again? Y/N: n

>>> 

I know I’m being a pain but this is all appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:31:10+00:00Added an answer on June 12, 2026 at 6:31 pm

    You can just make a function out of the code and return the value of the continue_game variable. Here is a minified version of your code wrapped in a function, along with an example of its usage:

    def continue_game():
        while True:
            user_continue = raw_input("Would you like to play again? Y/N: ").upper()
            if user_continue in ["Y", "YES", "N", "NO"]:
                return user_continue in ["Y", "YES"]
            else:
                print "Press Y or N"
    
    if continue_game():
        print "continue"
    else:
        print "exit"
    

    UPDATE: regarding your full code, to fix the error, you need to delete the following line:

    continue_game = True
    

    and replace:

    while continue_game == True:
    

    with:

    while continue_game():
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.