[Tutor] help with alternate execution

Dave Angel davea at ieee.org
Fri Oct 2 02:41:37 CEST 2009


You top-posted, and sent the mail to me privately (off-list).  That's 
not how mailing lists work.

wrobl1rt at cmich.edu wrote:
> Thank you for the reply.. I tried putting the print repr(n)
> before I defined 'n' with raw_input. My script looks like
> this------
>
>
> def divisible(n):
>    if n%3 == 0:
>        print n, "is divisible by 3"
>    else:
>        print n, "is not divisible by 3"
> n= raw_input("enter a number= ")
> print repr(n)
>
> print divisible(n) 
>
> In the shell, it gives me this error--------
>
> Traceback (most recent call last):
>   File "C:\Users\RY4N\Desktop\CMU
> stuff\BIS228\is_divisible_by_3", line 11, in <module>
>     print divisible(n)
>   File "C:\Users\RY4N\Desktop\CMU
> stuff\BIS228\is_divisible_by_3", line 4, in divisible
>     if n%3 == 0:
> TypeError: not all arguments converted during string formatting
> ----------
> I don't understand what the problem is
>
>   

You added the print, but you didn't look at the result, did you?

So, what was the repr(n) value?  In particular, what is the type of n ?  
Is it what you expected?

DaveA



More information about the Tutor mailing list