Bird
0
0

Find the error in this code:

medium📝 Debug Q6 of 15
Python - Variables and Dynamic Typing
Find the error in this code:
value = 5
if type(value) = int:
    print("Integer")
AUse 'is' instead of '=' in the if condition
BUse '==' instead of '=' in the if condition
CUse '!=' instead of '=' in the if condition
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Identify the operator in the if condition

    The code uses single equals = which is assignment, not comparison.
  2. Step 2: Correct the operator for comparison

    To compare types, use double equals == in the if condition.
  3. Final Answer:

    Use '==' instead of '=' in the if condition -> Option B
  4. Quick Check:

    Comparison needs '==' not '=' [OK]
Quick Trick: Use '==' for comparisons, '=' is assignment [OK]
Common Mistakes:
MISTAKES
  • Using '=' instead of '==' in conditions
  • Confusing assignment with comparison
  • Syntax errors from wrong operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes