Let’s see some Print for loop in single-line python examples.
Python Print 1 to 10 in One-line code
Compress Two Lines in One Line (print from 0 to 9).
for i in range(10): print(i)
Print square of the number in for loop one line python
List Comprehension, The code squares the first ten numbers and stores them in the list
print([i**2 for i in range(10)])
Do comment if you have any doubts and suggestions on this Python for loop topic.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.