عبارة if-else
تعرف على وظيفة وخصائص العبارة if-else مفتاح في Python للتعامل مع شروط متعددة.
سنغطي ما يلي...
سنغطي ما يلي...
What if we want to execute a different set of operations in case an if
condition turns out to be False
?
That is where the if-else
statement comes into the picture.
Structure
The if-else
statement looks something like this:
Press + to interact
There’s nothing too tricky going on here. If the condition turns out to be True
, the code block immediately following the if
condition would be executed. If the condition turns out to be False
, the code after the else
keyword would be executed.
Hence, we can now perform two different actions based on the condition’s value.
The else
keyword will be on the same indentation level as the ...