Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

junglebooboo Group Title

python game of stones. Please help

  • one year ago
  • one year ago

  • This Question is Closed
  1. junglebooboo Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Here's my code numStones = 100 def isValid(player1): try: player1 = int(player1) if player1 in range(6): return True else: return False except ValueError: return False while numStones > 0: print "Welcome to this game of stones, there are now %s stones remaining in the pile" % (numStones) player1 = isValid(raw_input('enter integer')) while not isValid(player1): print 'boo' For some reason, even though I have tested my isValid statement, and it returns True and False as expected, I am not able to access it with the while not isValid statement? how come?

    • one year ago
  2. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    When you call isValid() with raw_input, you're passing a string. The boolean that isValid() returns is assigned to the player1 variable. Then you call isValid() with the boolean in the while statement.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.