python simple function error ?

Posted by abhilashm86 on Stack Overflow See other posts from Stack Overflow or by abhilashm86
Published on 2010-06-06T05:33:57Z Indexed on 2010/06/06 5:42 UTC
Read the original article Hit count: 373

Filed under:
|
|

Here's a simple function to do simple math operations, when i call this from other program using import, output i get is none. When i remove def function, everything is working fine. What's the problem with defining this function? I'm new to python.

def calci(a, op, b): 

    if op == '+':
        c = a + b

    elif op == '-':
        c = a-b

    elif op == '*':
        c= a*b

    elif op =='/':
        if(b == 0):
            print('can\'t divide')

            c = a/b


            print('value is',c)
            return c

result  = calci(12,'+', 12)

print(result)  nter code here

© Stack Overflow or respective owner

Related posts about python

Related posts about beginner