[Tutor] help with alternate execution

vince spicer vinces1979 at gmail.com
Tue Sep 29 19:11:28 CEST 2009


On Tue, Sep 29, 2009 at 10:59 AM, <wrobl1rt at cmich.edu> wrote:

> I'm trying to make a very simple example to show alternate execution... if
> a
> number is divisible by 3 it will say so and if it isnt, it will say so.
> Heres my
> program----
>
> n= raw_input("enter a number= ")
> def divisible(n):
>    if n%3 == 0:
>        print n, "is divisible by 3"
>    else:
>        print n, "is not divisible by 3"
> print divisible
>
> when I try it out, and enter 3, I get this------
>
> enter a number= 3
> <function divisible at 0x02CC06B0>
> >>>
>
> I'm not sure why I am getting this and am not quite sure what this means...
> could someone explain what I am doing wrong here and why it is telling me
> this?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

You need the call the function with the user input

n = raw_input("enter a number= ")
def divisible(n):
   if n%3 == 0:
       print n, "is divisible by 3"
   else:
       print n, "is not divisible by 3"
print divisible(n)


Vince
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090929/92d103fa/attachment.htm>


More information about the Tutor mailing list