You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your program logic is correct, but the error occurs because of incorrect indentation.
In Python, indentation is required after if, elif, and else statements.
❌ Problems in Your Code
Missing indentation after if and elif
Nested if inside division option also not indented
Activity
HARDIKSINGH07 commentedon Jan 18, 2026
Basic Calculator Program
print("Select operation:")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
choice = input("Enter your choice (1/2/3/4): ")
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
print("Result =", num1 + num2)
elif choice == '2':
print("Result =", num1 - num2)
elif choice == '3':
print("Result =", num1 * num2)
elif choice == '4':
if num2 != 0:
print("Result =", num1 / num2)
else:
print("Error: Cannot divide by zero!")
else:
print("Invalid choice")
JokoKusnandi commentedon Feb 24, 2026
Your program logic is correct, but the error occurs because of incorrect indentation.
In Python, indentation is required after if, elif, and else statements.
❌ Problems in Your Code