I am trying to create a basic program in python, where I perform calculations based on sentences. For that I have created if/else conditions but after running the program it is taking the first condition every time, do you have any idea why it is happening?
import re
query = 'plus 5 and 3'
def multiply(query):
query = '*'.join(re.findall('\d+',query))
print(f'{eval(query)}')
return f'Answer is {eval(query)}'
def addition(query):
query = '+'.join(re.findall('\d+',query))
print(f'{eval(query)}')
return f'Answer is {eval(query)}'
def subtract(query):
query = '-'.join(re.findall('\d+',query))
print(f'{eval(query)}')
return f'Answer is {eval(query)}'
def divide(query):
query = '/'.join(re.findall('\d+',query))
print(f'{eval(query)}')
return f'Answer is {eval(query)}'
if 'multiplication' or 'multiply' in query:
print(multiply(query))
elif 'addition' or 'add' or 'plus' in query:
print(addition(query))
elif 'subtraction' or 'subtract' or 'minus' in query:
print(subtract(query))
elif 'division' or 'divide' in query:
print(divide(query))