View Single Post
Old Jan 20th, 2008, 3:10 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,798
Rep Power: 5 Sane will become famous soon enough
Re: My pyguessinggame

Yes. I'm getting tired of it, but that doesn't mean I won't help you. I don't want to be the one who ignores you based on inability to code. We all started somewhere, and so you don't deserve that. I just wish you put a bit of effort into trying to fix the syntax errors.

In reference to your last post's code:

eg.) If guess is >0 AND <=100 AND > answer:
             print ' too low'

You can get an "if" statement to work that way, like so:

Python Syntax (Toggle Plain Text)
  1. if (guess > 0) and (guess <= 100) and (guess > answer):
  2. print "Too Low"

The main thing you were missing is you have to include the variable 'guess' for each relationship. Python can't just assume what variable you want to use for the next relationship.

Note, the brackets aren't necessary. It's just to help show how the statement is broken up.

But as for the logic of your program, it's stuck in an infinite loop, because you don't keep asking the user for a new number. You only ask him once. That's one of your problems.
Sane is offline   Reply With Quote