mpappu - 1 year ago 44

Python Question

I have a list of numbers and I want to, for (for example) the first term and the second term, perform every function in my imported

`math`

`import math`

list = [1, 2, 3]

#do stuff that will print (for example) 2+1, 2-1, 2/1, etc.

Answer

Here's a simple method. You'll need to specify what happens if the function doesn't expect two arguments.

```
for name in dir(math):
item = getattr(math, name)
if callable(item):
item(list[0], list[1])
```