这是我的密码,我不知道为什么不起作用。。你知道吗
shape = str(input("Type of Shape: "))
if(shape == "Triangle"):
height = int(input("Enter a height: "))
for i in range(height):
for j in range(i+1):
print("*", end = " ")
elif(shape != "Rectangle" or shape != "Triangle"):
print("Unavailable shape, ask for valid shape")
如果运行程序并键入三角形,然后键入5这样的高度,则打印出来:
* * * * * * * * * * * * * * *
我使用的是python3.6.3,所以我不知道这是否起到了很大的作用。你知道吗
可以用下面的一行替换内部for循环
print("*"*(i+1))
相关问题 更多 >
编程相关推荐