mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-13 13:00:27 -05:00
fix(curriculum): clarify elif evaluation order (#65563)
This commit is contained in:
@@ -111,10 +111,10 @@ There might be situations in which you want to account for multiple conditions.
|
||||
Here's the syntax:
|
||||
|
||||
```python
|
||||
if condition:
|
||||
pass # Code to execute if condition is True
|
||||
if condition1:
|
||||
pass # Code to execute if condition1 is True
|
||||
elif condition2:
|
||||
pass # Code to execute if condition2 is True
|
||||
pass # Code to execute if condition1 is False and condition2 is True
|
||||
else:
|
||||
pass # Code to execute if all conditions are False
|
||||
```
|
||||
|
||||
@@ -711,7 +711,7 @@ if age >= 18:
|
||||
print('You are an adult') # You are an adult
|
||||
```
|
||||
|
||||
- **`elif` Statement**: These are conditions that come after an `if` statement. If the `elif` condition evaluates to `True`, then that block of code will run.
|
||||
- **`elif` Statement**: These are conditions that come after an `if` statement. An `elif` block runs only if all previous conditions evaluate to `False` and its own condition evaluates to `True`.
|
||||
|
||||
```py
|
||||
age = 16
|
||||
|
||||
@@ -13,7 +13,7 @@ The `if...elif...else` statement is used to check multiple conditions in order.
|
||||
if condition1:
|
||||
# Code to execute if condition1 is True
|
||||
elif condition2:
|
||||
# Code to execute if condition2 is True
|
||||
# Code to execute if condition1 is False and condition2 is True
|
||||
else:
|
||||
# Code to execute if all conditions are False
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user