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
Python merges two lists without duplicates could be accomplished by using a set. And use the + operator to merge it. Python merge list without… Read More »Python merge two lists without duplicates | Example code
There is no tuple comprehension in Python. Comprehension works by looping or iterating over items and assigning them into a container, a Tuple is unable… Read More »Tuple comprehension Python | Example code
Use PEP 8 recommended method to check if the list is empty in Python. In the method doing “Truth Value Testing” where check if the… Read More »Python if list is empty | Example code
Use the + operator to Combine two lists in Python. There are many ways to join or concatenate, two or more lists in Python. Like,… Read More »Combine two lists Python | Example code
Use not-operator expression in if statement to check string not empty in Python. Python string not empty example Simple example code. Output: Another example with… Read More »Python string not empty | Example code
Use format() method to formatting a float number. Here are 2 ways to print format float in Python. Python print format float Example Simple example… Read More »Python print format float | Example code
Use comma “,” to separate strings and variables while printing int and string in the same line in Python or convert the int to string.… Read More »Python print int and string in same line | 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