Easy function, please help.

2011-02-08 Thread Nanderson
def num_digits(n): count = 0 while n: count = count + 1 n = n / 10 return count This is a function that basically says how many digits are in a number. For example, print num_digits(44) 2 print num_digits(7654) 4 This function counts the number of decimal digits in a

Re: Easy function, please help.

2011-02-08 Thread Nanderson
( int(n) ) or at least check its type: if not isinstance(n, int):    raise TypeError(WTF you didn't pass me an int) Michael On Wed, Feb 9, 2011 at 12:52 AM, Nanderson mandersonrandersonander...@gmail.com wrote: def num_digits(n):    count = 0    while n:        count = count + 1

Running python scripts from the command line.

2011-01-31 Thread Nanderson
I've recently started to program. Python is my first language, so I'm a complete beginner. I've been trying to call python scripts from the command line by entering this command into it: python test.py But it gives me this error message: python test.py File stdin, line 1 python test.py

Re: Running python scripts from the command line.

2011-01-31 Thread Nanderson
On Jan 31, 6:54 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Mon, Jan 31, 2011 at 9:43 PM, Nanderson mandersonrandersonander...@gmail.com wrote: I've recently started to program. Python is my first language, so I'm a complete beginner. I've been trying to call python