Sunday, 4 February 2024

Python Learning Session-03 - Conditional Execution

Conditional Steps



                                                                    Indentation

                   Increase indent indent after an if statement or for statement (after : )

                   Maintain indent to indicate the scope of the block (which lines are affected by the if/for)

         Reduce indent back to the level of the if statement or for statement to indicate the end of the block

         Blank lines are ignored - they do not affect indentation

                              •         Comments on a line by themselves are ignored with regard to indentation


                                                                    The try / except Structure

         You surround a dangerous section of code with try and except

         If the code in the try works - the except is skipped

         If the code in the try fails - it jumps to the except section
































 









No comments: