# Newbie: Explain My Problem

ChuckDubya at gmail.com ChuckDubya at gmail.com
Wed Jun 29 09:11:17 CEST 2005

```Code:

#The Guess My Number Game

import random
num = ""
guess = ""
counter = 7
num = random.randrange(1, 100)
print "I'm thinking of a whole number from 1 to 100."
print "You have ", counter, " chances left to guess the number."
print
guess = int(raw_input("Your guess is: "))
while counter != 0:
if guess == num:
print "You guessed the number, ", num, " in ", counter-6, "
guesses!"
elif guess > num:
counter = counter - 1
print
print "The number is less than your guess."
print "You have ", counter, " chances left to guess the
number."
guess = int(raw_input("Your guess is: "))
else:
counter = counter - 1
print
print "The number is greater than your guess."
print "You have", counter, " chances left to guess the number."
guess = (raw_input("Your guess is "))
if counter == 0:
print "You idiot, my number was", num,"!"
print "YOU LOSE!"
raw_input("Hit the enter key to exit.")

Two things wrong happen:
- Dialogue switches from saying "number is greater" to "number is
less", regardless of guess
- Lets user guess when user has no more guesses left in "counter"
variable.

Please explain to me what's wrong with my program.

```