简体   繁体   English

如何打印完整的金字塔?

[英]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?有人可以纠正我关于此代码的问题吗?

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. Python 使用缩进(制表符或空格)而不是括号({})来确定函数的范围,因此缩进对于您的代码正确运行至关重要。 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) PS,您可以在插入代码时使用代码示例按钮(看起来像{} 的按钮)以使您的代码片段更具可读性(考虑到它是 Python,这一点非常重要)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM