我有一个循环创建菱形的代码,但我希望它被反转。在
width = int(input("Please enter a width: "))
i = 1
while i < width*2:
if i < width:
print("-" * (width-i) + " *" * i + "-" * (width-i))
else:
print("-" * (i-width) + " *" * (2*width-i) + "-" * (i-width))
i += 1 [EDIT: formatting mistake]
我的输出如下:
^{pr2}$但我希望它是这样的:
* * * * *
- * * * *-
-- * * *--
--- * *---
---- *----
---- *----
--- * *---
-- * * *--
- * * * *-
* * * * *
请帮忙!在
相关问题 更多 >
编程相关推荐