Junior — Middle
Could you explain what the 'indent' term means in Python language and why it is needed?
sobes.tech AI
Answer from AI
In Python, indentation refers to spaces or tabs at the beginning of a line that define code blocks. They are mandatory because Python uses them instead of curly braces to indicate nesting. For example, the body of a function or a conditional statement is indented:
if x > 0:
print("Positive number")
else:
print("Zero or negative number")
Without proper indentation, the code will not execute and will raise an error. Indentation makes the code readable and structured.