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 8742805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:33:52+00:00 2026-06-13T11:33:52+00:00

So I have been working on a two player guess the number program. But

  • 0

So I have been working on a two player “guess the number” program.
But im just having trouble with one thing.

So here’s code:

import time
import random
thenumber = random.randint(1, 10)
print "Welcome to Noah's Two Player guess a number game."
print "What is player one's name?"
player1 = raw_input()
print "What is player two's name?"
player2 = raw_input()
print "Well " + player1 + " and " + player2 + ", are you ready to play?"
choice = raw_input()
if choice == yes:
    print player1 + ", pick a number from 1 to 10."
    player1guess = raw_input()

    print player2 + ", pick a number from 1 to 10."
    player2guess = raw_input()

    print "Calculating..."
    time.sleep(3)

    p1 = thenumber - player1guess
    p2 = thenumber - player2guess

    if p1 > p2:
        print player1 + " won!"

    elif p2 > p1:
        print player2 + " won!"

Everything is running smoothly until I get this error:

Traceback (most recent call last):
  File "C:\Python27\Script 1", line 11, in <module>
    if choice == yes:
NameError: name 'yes' is not defined

To my knowledge, I don’t think I have done anything wrong, but then again I am a beginner to python.

Someone please help me with this.

EDIT: (This is python 2.7 if it makes a difference)

  • 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-13T11:33:53+00:00Added an answer on June 13, 2026 at 11:33 am

    I guess you need quotes around yes : choice =='yes' , otherwise python will think that yes is a variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with SQL Server as a Developer a while. One thing
I have been working for two weeks on JamVM, a small but powerful Java
Ive been working on this tempeture converter but have been troubling conbining the two
I have been fine hitherto working with lightboxes and just simply having an image
I have now been working as a web developer for two weeks and have
I've been working at this for two days and have not had much luck.
I've been working on an application for a little over two years and have
I have been working on this app for at least 3-4 months and just
I have been working on a project on and off, but I haven't touched
I have been working with this for a whole day but i cannot find

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.