Single line while loop Python | Example code
If the while loop body consists of one statement, write this statement into the same line: while True: print(‘Hello’). Even you can write a single… Read More »Single line while loop Python | Example code
If the while loop body consists of one statement, write this statement into the same line: while True: print(‘Hello’). Even you can write a single… Read More »Single line while loop Python | Example code
You can give a condition expression in while to test list is empty or not or you can use if statement for it. Python while… Read More »Python while list is not empty | Example code
While 1 is a bit kinder to old versions of Python. While 1 will create an infinite loop in Python. The most pythonic way will… Read More »While 1 in Python Example | Code
Traverse a string in Python using while loop is simple, see below code. It’s making sure that the condition is correct in every iteration. Example… Read More »How to traverse a string in Python using while loop | Example code
Using the for loop construct can Iterate through the string in Python. If you need access to the index as you iterate through the string,… Read More »Iterate through string Python | Example code
To reverse for loop in Python just need to read the last element first and then the last but one and so on till the… Read More »Reverse for loop in Python | Example code
The list can Iterate backward in Python if read the last element first and then the last but one and so on till the element… Read More »Iterate backward Python | Example code
Simple Python one line if-else for a loop example code. For loop and if-else condition in one line python If and else inside a one-line… Read More »Python one line if-else for a loop | 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… Read More »While Boolean Python | Example code
Using a for loop with append method you can create a new list in for loop Python. Example creating a new list for each for… Read More »Create a new list in for loop Python | Example code