Control statements alter the flow of program execution in any language.
Here, we shall be exploring the if-elif-else structure.
Syntax:
if :
your code..
elif :
your code...
else :
your code...
Using the match statement
The match statement is used when there are multiple cases and need to be made more readable and maintainable.
Case _: indicates the default case / else case. This case will execute when none of the other cases are matching the condition
Syntax:
match
case :
your code ...
case :
your code ...
case _:
your code for else case
Example:
No comments:
Post a Comment