diff --git a/python_basics/if/README.md b/python_basics/if/README.md new file mode 100644 index 0000000..fdae6a0 --- /dev/null +++ b/python_basics/if/README.md @@ -0,0 +1,37 @@ +# Flow Control if, elif, else +{:.no_toc} + + + +## The goal + +If I would have... + +Questions to [David Rotermund](mailto:davrot@uni-bremen.de) + +**Logic blocks need to be indented.​ Preferable with 4 spaces!** + +## [The if statement](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement) + +```python +if i == 1:​ + print("if")​ +elif i == 2:​ + print("elif brach A")​ +elif i == 3:​ + print("elif brach B")​ +else:​ + print("else -- default")​ +``` + +## The full statement + +```python +if_stmt ::= "if" assignment_expression ":" suite + ("elif" assignment_expression ":" suite)* + ["else" ":" suite] +``` +