Syntax Error (सिंटैक्स त्रुटि) :-
Syntax Error (सिंटैक्स त्रुटि) तब होती है जब Python Program लिखते समय उसके लिखने के नियम (Syntax Rules) का पालन नहीं किया जाता। Python सबसे पहले Program की Syntax को जांचता है। यदि कोई गलती मिलती है, तो Program Run होने से पहले ही रुक जाता है और SyntaxError प्रदर्शित करता है।
English:
A Syntax Error occurs when the rules (syntax) of the Python programming language are not followed. Python checks the syntax before executing the program. If it finds any mistake, the program stops before execution and displays a SyntaxError.
Syntax Error क्यों आती है? (Causes of Syntax Error) -
1. Colon (:) भूल जाना — Missing Colon
Wrong Code:
Output:
Correct Code:
2. Parentheses () पूरा न करना — Missing Parentheses -
Wrong Code:
Output:
Correct Code:
3. Quotes (" या ') बंद न करना — Missing Quotation Marks -
Wrong Code:
Output:
Correct Code:
4. Python Keyword गलत लिखना — Misspelled Python Keyword -
Wrong Code:
Output:
Correct Code:
5. Comma (,) भूल जाना — Missing Comma -
Wrong Code:
Output:
Correct Code:
6. Statement गलत लिखना — Incorrect Statement Structure -
Wrong Code:
Output:
Correct Code:
Output: