Back

Pattern Codekata

Created 2 years ago
85 Views
2 Comments
SoorajM9zVQ8
@SoorajM9zVQ8
SoorajM9zVQ8
@SoorajM9zVQ8Profile is locked. Login

7) Write a code to generate an inverted half pyramid pattern using stars.

Input Description:
Given an integer R indicates number of rows.

Where 1<=R<=100.

Output Description:
Print the star inverted pyramid with the given integer R.

Sample Input :
5
Sample Output :
*  *  *  *  *
*  *  *  *
*  *  *
*  *
*

My Code:

n = int(input())
for i in range (n,0,-1):
    for j in range(0,i):
        print("*", end ="  ")
    print()

The output is the same but the test cases are failing. The same issue is with other pattern problems (prob 1) where space is involved (end = " "). Any reason for this? Please guide!

Comments (2)
Please login to comment.