Skip to content

Updated the nested if statement syntax to reflect correct indentation #665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions indentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Whitespace at the beginning of the line is called 'indentation'. These whitespaces or the indentation are very important in python. In a Python program,
the leading whitespace including spaces and tabs at the beginning of the logical line determines the indentation level of that logic.

* In most programming languages, indentation has no effect on progamming logic. It is used to align statements to make the code more readable.
However, in python, indentation is used to associate and group statements.

All statements within the same block must have the same indentation level. Typically, one tab or 4 spaces are used per level.

All statements inside a block should be at the same indentation level..


Below is the correct syntax for nested conditions with proper indentation:

if <condition>:
-Statements-
if <contion>:
-statements-

"""
# example:
user = int(input ("enter any digit.. "))
if user <=10:
if user>=5:
print("entered number is less than 10 and greater than 5")
else:
print("entered number is less than 5")
else:
print("entered number is greater than 10")