diff --git a/guide/english/python/if-elif-else-statements/index.md b/guide/english/python/if-elif-else-statements/index.md index 322d362312..98d0049923 100644 --- a/guide/english/python/if-elif-else-statements/index.md +++ b/guide/english/python/if-elif-else-statements/index.md @@ -5,13 +5,13 @@ title: If / Elif / Else Statements ## If / Elif / Else Statements The `if`/`elif`/`else` structure is a common way to control the flow of a program, allowing you to execute specific blocks of code depending on the value of some data. If the condition following the keyword `if` evaluates as `True`, the block of code will execute: + Note that parenthesis are not used before and after the condition check such as in other languages. ```python if True: print('If block will execute!') ``` - ```python x = 5 @@ -20,11 +20,12 @@ if x > 4: ``` > **Tips** : You can use **1** as alternative to **True** and **0** as an alternative to **False** -_Example_: +Example: ```python if 1: # 1 evaluates to true print('If block will execute!') ``` + ***Else statement*** You can optionally add an `else` response that will execute if the condition is `False`: @@ -34,7 +35,7 @@ if not True: else: print('Else statement will execute!') ``` -Or you can also see this example +Or you can also see this example: ```python y = 3 @@ -43,7 +44,6 @@ if y > 4: else: print("The condition wasn't true!") #this statement executes ``` - *Note that there is no condition following the `else` keyword - it catches all situations where the condition was `False`* ***Elif statement*** @@ -67,7 +67,7 @@ else: ***Nested if statement*** -We can also create nested if statements for decision making. Before preceding please refer to the indentation guide once before preceding. +We can also create nested `if` statements for decision making. Before preceding, please, refer to the indentation guide once. Let's take an example of finding a number which is even and also greater than '10': ```python @@ -85,6 +85,7 @@ Output ```python This number is even and is greater than 10 ``` + This was just a simple example of a nested if statement. Please feel free to explore more online. While the examples above are simple, you can create complex conditions using boolean comparisons and boolean operators.