[Tutor] Please critique my guessing game program.
smith-matt at tiscali.co.uk
Tue Jul 13 20:36:53 CEST 2004
I just started reading about python a couple of days ago and have just
written my first program, a guessing game (project suggested b o by the
Python Bibliothecha). I intend to extend the program to make it more
user friendly but I'd like to get some initial feedback to catch any
poor programming or bad habits as soon as possible. Here's the program:
# A guessing game program.
# By Matt Smith
# Function to create a random number between 1 and 100.
# Game loop.
guesses = 1
while guess != number:
if guess > number:
guess = input("Too high, try again. ")
guess = input("Too low, try again. ")
guesses = guesses + 1
print "Well done, you got it in",guesses,"goes."
# Main program.
# Introduce the program.
print "* Guessing Game *"
# Think of a number.
number = Random100()
# Play the game.
print "I am thinking of a number between 1 and 100"
guess = input ("What is your first guess? ")
# End of program.
Thanks for the help,
More information about the Tutor