Below is the program to generate the following pattern.

Python program to generate patterns
n=int(input("Enter the number :"))
k=1
for i in range(1,n+1):            # outer loop
  for j in range(1,i+1):          # inner loop
    print(str(k)+" ",end="")
    k=k+1
  print("\r")   
   

Python program to generate patterns

Output:

Python program to generate patterns

Explore More

end and sep in Python

end in Python The end is a parameter in Python’s built-in print() function/method that controls what character(s) are printed at the end of the printed text.  Syntax : Output :

f-strings in Python

Python offers a powerful feature called f-strings (formatted string literals) to simplify string formatting and interpolation. f-strings is introduced in Python 3.6 it provides a concise and intuitive way to embed expressions and variables

Python tutorials

We are starting a Python Tutorials Series for Beginners and Professionals. In these Python Tutorials, we will cover all the features of Python. You will learn from basic to advanced-level features