how to write a function to make operation as a argument in the function

luofeiyu elearn2014 at gmail.com
Thu Aug 14 03:32:19 EDT 2014


I want to write a function to make operation as a argument in the function.

|def   fun(op,x,y):
     return(x op y)|

it is my target for the funciton:

if op ="+" fun(op,3,9) =12
if op ="*" fun(op,3,9) =27

How to write it?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140814/4361eb27/attachment.html>


More information about the Python-list mailing list