In python "Indentation Error: Unexpected Indent" is a very important error that you should know.
In python, it is very important to not add unnecessary spaces or a tab in front of a code line. That's the main reason these errors are caused.
For example in the below code, if you see the third line there is additional space before the beginning of the print function.
print("String Manipulation")
print('String Concatenation: done with the "+" sign.')
print('e.g. print("Hello" + "world")')
print("New lines can be created with a backslash and n.")
The simple thing you need to do in order to overcome this Indentation Error: Unexpected
Indent is to remove the additional space in front of line number 3.
Solution:
print("String Manipulation")
print('String Concatenation: done with the "+" sign.')
print('e.g. print("Hello" + "world")')
print("New lines can be created with a backslash and n.")
This will give you a successful output.

No comments:
Post a Comment