Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def operate(operator, *args):
- operator = operator
- counter = 0
- result = 0
- if operator == '+':
- for i in args:
- result += i
- return result
- elif operator == '-':
- for i in args:
- if counter == 0:
- result = i
- counter += 1
- continue
- result -= i
- return result
- elif operator == '*':
- result = 1
- for i in args:
- result *= i
- return result
- elif operator == '/':
- for i in args:
- if counter == 0:
- result = i
- counter += 1
- continue
- result /= i
- return result
- print(operate("/", 10, 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement