sanjjeev dutt
sanjjeev dutt

Reputation: 19

How to print full pyramid?

I want to print a full pyramid.

Below is the code:

num = int(input('enter the No of Rows '))

for i in range(0,num):
     for j in range(0,m-i-1):
            print(' ',end="") 
    for k in range(0,(2*i+1)):
            print('*',end="")   
    print()            

But during compilation it shows error:

File "<tokenize>", line 6
    for k in range(0,(2*i+1)):
    ^ IndentationError: unindent does not match any outer indentation level

Can Someone please correct me regarding this code?

Upvotes: 1

Views: 178

Answers (1)

Kyle Marcus Enriquez
Kyle Marcus Enriquez

Reputation: 118

Python makes use of indents (tabs or spaces) instead of brackets({ }) to determine the scope of a function so indentation is crucial for your code to function correctly. Double check to see if you indented correctly or to see if you mixed any spaces in with your tabs.

PS, you can use the Code Sample button (the one that looks like {}) when inserting code to make your code snippet more readable (which is very important considering it's Python)

Upvotes: 2

Related Questions