Nested Loops in Python

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

# n=int(input("Enter the limit"))
# for i in range(1,n+1,1):
#     print(i*i)
# n=int(input("Enter a number"))
# for i in range(1,11,1):
#     print(n*i)

# Nested loop

# for i in range (1,6,1):  # outer
#     for j in range(1,6,1):  #inner
#         print(i,end="  ")
#         print(j,end="  ")
#     print()         

# Program for Start Pyramid
n=int(input("Enter the limit"))
for i in range (1,n+1,1): 
    for j in range(1,i+1,1):
        print(j,end=" ")
    print()    


 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses
Image

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *