English

Write one example of the following in Python: Syntax Error - Computer Science (Python)

Advertisements
Advertisements

Question

Write one example of the following in Python:

Syntax Error

Very Short Answer
Advertisements

Solution

if x = 50:
    print("Hello")

In this statement, the assignment operator (=) is used instead of the comparison operator (==). This results in a syntax error because Python does not allow assignment in a condition.

shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Set 4

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×