Hi William,
Just a word of warning, you should get used to using 'raw_input()'
rather than 'input()' in your
progams.
Why? Because input() attempts to run whatever you type in as a Python
program. If you want to know why that's a problem, try running your
progam. When it asks you to "Enter the number: " type in this:
open('test.txt', 'w')
Your program will crash. But look in the directory where you ran it,
and you'll see a blank 'test.txt' document! Obviously, it's just as
easy to delete files, and cause other malicious damage.
Obviously, this isn't much of a problem if you're just writing a small
game as a learning excercise. But it's a good habit to practice secure
coding whenever possible.
raw_input saves anything typed in as a string. Which is good, because
you don't want people to be able to execute arbitrary code using your
program. But it's bad, because you can't do mathematics with a string.
So you need to use 'type casting', which you might not know about yet,
to turn the string into a number.
Try this instead:
number = int(raw_input("Enter the number: "))
Your program will still look the same, but it'll be a lot safer.
--
Seen in the release notes for ACPI-support 0.34:
'The "I do not wish to discuss it" release
* Add workaround for prodding fans back into life on resume
* Add sick evil code for doing sick evil things to sick evil
screensavers'
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor