if statement in for loop Python | Example code

Let’s see how you can use the if-else conditional statement with for loop in python. Output: Else block is executed statement in for loop Python Output: 123No Break Else block is NOT executed using break keyword Output: 1 Do comment if you have any doubts and suggestions on this Python code. RohitDegree in Computer Science Read More…


Python if True statement | Example code

Python if True statement works on if the given expression is true. If the statement evaluates the condition as the boolean expression evaluates if it’s TRUE, then the block of the statement(s) inside the if statement is executed. The general Python syntax for a simple if statement is: Python if boolean true example code Simple Read More…


Python print type of variable | Example code

Use the Python type() built-in function to check the variable type and after that show the result in the console with the help of the print method. If want to check if a variable is of a given type, use the isinstance method. How to determine a Python variable’s type Example Python simple example code Read More…


While Boolean Python | Example code

Python While loop uses the Boolean value to executes the loop body while the expression evaluates to (boolean) “true”. You can use a variable as a condition for your while loop instead of just while True. If you don’t set value false then the loop will run for infinite. Example While boolean in Python While Read More…


What is Python empty string | Example code

Python string is called an empty string if the string doesn’t have any character, whitespace whatsoever. But if the string has multiple white spaces or single space or tab spaces then it is a blank string. Example Create and check an empty string in Python. Simple python example code. In a Boolean context, null / Read More…



Python create empty string | Example code

Use “” to create an empty string in Python. There should be no char or whitespace in the string. Python creates an empty string Example Python simple example code initializes a string containing no characters and no whitespace and checks if String is empty. To check if the string is empty or not, use a Read More…


Python if statement string contains substring or word | Example code

Best to check string contains substring or not is using the in operator in Python. The in operator is generally used with if statement to check string contains a word or not. 99% of use cases will be covered using the keyword, in, which returns True or False: Note: Does Python have a string ‘contains’ Read More…


Python if statement or operator | Examples code

Python “OR” operator will use in the if statement to test conditions and decide which execution path your programs will take. A if statement with or operator in Python Simple python example code using “OR” logical operator that evaluates as True if any of the operands is True. An example of an OR operator Use Read More…


Python If-Else Statement with OR Operator in Condition/Expression | Example code

Example code use or operator to combine two basic conditional expressions in Python If-Else Statement. In the example taking input value from the user. Output: RohitDegree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical. if statement in for loop Python | Example codePython Read More…