Python continue Statement

Python continue statement is used to skip the execution of the current iteration of the loop. We can’t use continue statement outside the loop, it will throw an error as “SyntaxError: ‘continue’ outside loop“. We can use continue statement with for loop and while loops. If the continue statement is present in a nested loop, it skips the execution …

Python continue Statement Read More »

Python break Statement

The break statement in Python is used to get out of the current loop. We can’t use break statement outside the loop, it will throw an error as “SyntaxError: ‘break’ outside loop“. We can use break statement with for loop and while loops. If the break statement is present in a nested loop, it terminates …

Python break Statement Read More »

Python while Loop

Python while loop is used to repeat a block of code until the specified condition is False. The while loop is used when we don’t know the number of times the code block has to execute. We should take proper care in writing while loop condition if the condition never returns False, the while loop …

Python while Loop Read More »

Python for Loop

Python for loop is used to iterate over a sequence of items. The for loop is implemented using the reserved keyword – for. The for-loop code is executed for each element of the sequence. We can get out of the for loop using the break statement. We can use continue statement to skip the execution …

Python for Loop Read More »

Python if else elif Statement

Python if-elif-else statement is used to write a conditional flow code. The statements are in the order of if…elif…else. The ‘elif’ is short for ‘else if’ statement. It’s shortened to reduce excessive indentation. The else and elif statements are optional. There can be multiple elif statements. We can have only one else block for an …

Python if else elif Statement Read More »

Python return Statement

The python return statement is used in a function to return something to the caller program. We can use the return statement inside a function only. In Python, every function returns something. If there are no return statements, then it returns None. If the return statement contains an expression, it’s evaluated first and then the …

Python return Statement Read More »