Saturday, 14 August 2021

Square pattern of star (*) using for loop

Following Python program will print square pattern of star (*) using for loop. Number of lines to be printed are entered by the user

Expected Output: If user enters lines = 3, output should be

* * * * * * * * *

Program Code:

lines = int(input("Enter number of lines:"))

for i in range(lines):    
   for i in range(lines):        
      print('*', end = '  ')    
   print()

Output of Program:

Enter number of lines:3 * * * * * * * * *


* * * * *


< Back to Python Loops >





No comments:

Post a Comment