indentation
Many popular languages such as C, and Java uses braces ({ }) to define a block of code, and Python uses indentation.
What is Indentation in Python?
Indentation in Python refers to the whitespaces at the start of the line to indicate a block of code. We can create an indentation using space or tabs. When writing Python code, we have to define a group of statements for functions and loops. This is done by properly indenting the statements for that block.
পাইথনে কোড ব্লক বুঝানোর জন্য কোন ব্র্যাকেট ব্যবহার করা হয় না৷ তাই ক্লাস বা ফাংশন লিখার সময় কোড ব্লকের শুরু বা শেষ বুঝাতে ইন্ডেন্টেশনের ব্যবহার করা হয়। সাধারণত এক ট্যাব বা চারটি স্পেস কে স্ট্যান্ডার্ড ধরা হয়।
def foo():
print("Hi")
if True:
print("true")
else:
print("false")
print("Done")
Note: In Python programming languages the indentation in code can be done by using two spaces or four spaces (or any other number of spaces), you just have to be consistent, although 4 spaces for each level of indentation is the best practice.
Last updated