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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:58:28+00:00 2026-05-24T20:58:28+00:00

I am creating a number guessing game to help myself learn how to use

  • 0

I am creating a number guessing game to help myself learn how to use Google’s App Engine. I store the current answer as a random number in the datastore. Each time the user guesses I want to pull the answer out in a GqlQuery and compare to the users guess. When I use the GqlQuery to pull the answer it returns ‘None’, and I don’t know why or what to change to get the random number instead.

Here is where I store the answer –

class Answer(db.Model):
    ans = db.IntegerProperty()

Here is how I store the random number when the user creates a new game –

thisanswer =(random.randint(1, 100))
answer = Answer(ans = thisanswer)
answer.put()

And I try to pull the answer out when the user submits a guess so I can compare to their guess like this-

q = db.GqlQuery("SELECT * FROM Answer")
q = q.fetch(1)
for p in q:
    answer = p.ans

So when I try

if guess > answer:
    msg = "Too high!"
elif guess < answer:
    msg = "Too low!"

etc. I get the msg “Too high!” every time. So I changed the “Too high!” msg to this-

msg = "Too high! " + str(answer)

and what I get is-

“Too high! None”

Why is this code returning a value of ‘None’? What do you recommend I change to get the random number that I expect to get. I have been following the App Engine Python docs for the datastore but obviously I am overlooking something. Thanks for any insight on this.

  • 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-05-24T20:58:29+00:00Added an answer on May 24, 2026 at 8:58 pm

    It’s possible there are no answers in the database. Verify it with:

    msg = "Total answers in database: " + str(Answer.all().count())
    

    A more elegant way of getting the first answer in the database would be:

    answer = Answer.all().get()
    # or (equivalent)
    answer = db.GqlQuery("SELECT * FROM Answer").get()
    
    if answer is not None:
      number = answer.ans
    else:
      number = None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using c# (asp.net) i'm programmatically creating several drop down lists (random number). the user
Creating a google map with store locations within 50 miles of user entered address.
I am creating random number generator in Java as part of program I am
In my current project, I am creating a number of user controls, some of
I'm testing a Google App Engine application where I've started using task queues to
How would I go about creating a random number generator which has a bias
In my app I'm creating my own placemarks and I need the street number
I'm creating a gridview dynamically based on number of users selected but want to
I am creating a windows service that starts a number of slave processes. In
We're having a significant number of problems creating a bulk upload function for our

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.