Would someone be able to tell me why this code doesn't work?
Task specs:
*Our function should take a single list of strings as an argument, containing our first operand, followed by an operator and then the 2nd operand. eg: simple_calculator(['1', '+', '1' ]) #=> 2 The function should return 'Please enter valid format: [Operand, Operator, Operand]' for arguments that don’t match the required format The function should work with the following simple operators +, -, *, /, %, and should return'Please enter a valid operator [ +, -, /, , % ]' if any other operators are passed Assume that the operands are always numeric (floats or integers); no need to validate their data type
MY CODE:
def simple_calculator(input):
if type(input[1]) == int and type(input[2])==int
return
if input[1] == '+':
print(add(input[0],input[2]))
if input[1] == '-':
print(subtract(input[0],input[2]))
if input[1] == '/':
print(divide(input[0],input[2]))
if input[1] == '*':
print(multiply(input[0],input[2]))
else:
return "Please enter a valid operator [ +, -, /, *, % ]"
else:
return "Please enter valid format: [Operand, Operator, Operand]"