I wrote a Python programm that is ignoring the if loop. Could somebody please help me by telling me what I did wrong? Please see the code below:
class Check(): def __init__(self, op1, op2, op): self.op1 = op1 self.op2 = op2 self.op = op def main(): print("Enter first number: ") num1 = int(input()) print("Enter second number: ") num2 = int(input()) print("Enter operation: ") op=str(input()) if op == '+': return op1 + op2 elif op == '-': return op1 - op2 elif op == '*': return op1 * op2 elif op == '/': return op1 / op2 if __name__ == "__main__": main()
ifis not a loop. Second, your code just defines a class but no instance or method are ever created/called