my first real program blows up, can someone tell me why?
Martin P Holland
newsbunny at noether.freeserve.co.uk
Sun Mar 5 12:04:01 EST 2000
On Sun, 05 Mar 2000 10:26:05 -0600,
Jerry F. Davis <jfdecd at execpc.com> wrote:
> x = sys.argv[1]
> print 'now doing fib(', x, ')'
> fib(x)
x is a string not an integer, so in the while loop
in your function you are asking if an integer is <
a string.
fib(int(x))
will fix it but you might want to use a try: except:
to catch when the command line isn't an integer.
Play with the interpreter to discover which exception
you should catch.
atb
Martin
--
http://www.noether.freeserve.co.uk
http://www.kppp-archive.freeserve.co.uk
More information about the Python-list
mailing list