r(n))
>
> And if either of these were a real function you planned to use, you'd
> probably want to either cast n as an int ( int(n) ) or at least check
> its type:
>
> if not isinstance(n, int):
> raise TypeError("WTF you didn't pass me an int")
>
>
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
On Jan 31, 6:54 pm, Benjamin Kaplan wrote:
> On Mon, Jan 31, 2011 at 9:43 PM, Nanderson
>
>
>
>
>
>
>
>
>
> wrote:
> > I've recently started to program. Python is my first language, so I'm
> > a complete beginner. I've been trying to ca
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 "", line 1
python test.py