
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
What is unexpected indent in Python?\\\
Python not only insists on indentation, it insists on consistent indentation. If we indent one line by 4 spaces, but then if we indent the next by 3 (or 5, 6, .), we get this error of unexpected indent in python.
In the given code, line 3 has more spaces at the start than line 2. All lines of code in a block must start with exactly the same number of spaces. Both print statements must be indented same number of spaces. So the corrected code that does not show unexpected indent is as follows.
def a(): print "foo" print "baz"
- Related Articles
- \nQuery in Analytic view creating unexpected results in SAP HANA\n
- How to indent an if...else statement in Python?
- How to indent multiple if...else statements in Python?
- Indent Text with CSS text-indent Property
- Avoid Unexpected string concatenation in JavaScript?
- Five Unexpected Uses of Canva
- Usage of text-indent property in CSS
- Animate CSS text-indent property
- What is difference between self and __init__ methods in python Class?\n\n
- What does setattr() function do in Python?\n\n
- What does delattr() function do in Python?\n\n
- Indent the first line of a paragraph in CSS
- How to indent text in HTML by using CSS?
- What does built-in class attribute __name__ do in Python?\\\\n\\\\n
- Indent the text of a paragraph with CSS

Advertisements