Day 34 - Enumerate function in PythonThe enumerate function is a built-in function in Python that allows you to loop over a sequence (such as a list, tuple, or string) and get the index and value of each element in the sequence at the same time. Here's a basic example of how it works: #...1HJul 25, 2023 · 2 min readviveky.hashnode.dev
Day 33 - Short Hand if elseIf ... Else in One Line There is also a shorthand syntax for the if-else statement that can be used when the condition being tested is simple and the code blocks to be executed are short. Here's an example: a = 2 b = 330 print("A") if a > b else prin...Apr 23, 2023 · 1 min readviveky.hashnode.dev
Day 32 - Custom ErrorsRaising Custom errors In Python, we can raise custom errors by using the raise keyword. salary = int(input("Enter salary amount: ")) if not 2000 < salary < 5000: raise ValueError("Not a valid salary") In the previous tutorial, we learned about d...Apr 2, 2023 · 1 min readviveky.hashnode.dev
Day 31 - Finally keywordFinally Clause The finally code block is also a part of exception handling. When we handle exception using the try and except block, we can include a finally block at the end. The finally block is always executed, so it is generally used for doing th...Mar 30, 2023 · 1 min readviveky.hashnode.dev
Day 30 - Exception HandlingException Handling Exception handling is the process of responding to unwanted or unexpected events when a computer program runs. Exception handling deals with these events to avoid the program or system crashing, and without this process, exceptions...Mar 28, 2023 · 1 min readviveky.hashnode.dev