In today's article, we will simply try to print a start pattern using very basic functions and a single FOR loop. Usually, with such a task people tend to use two or more FOR loop which makes the code a bit difficult to understand. We will try to get the same output but with less number of codes. Follow along!
The below code is for a star pattern in which we want a maximum of 3 words in a single line.
for i in range(6):
if i<=3:
n = i
else:
n = 6-i
print(('Python '*n).center(len('Python ')*3, ' '))
The output is
Python
Python Python
Python Python Python
Python Python
Python
Hope! These 4 to 6 lines of code are easy to understand and implement.