正方向
height = int(input("please input height: ")) tmp = 1 while tmp <= height: width = tmp while width > 0: print("*", end="") width -= 1 print("") tmp += 1
测试结果:
反方向:
height = int(input("please input height: ")) while height > 0: tmp = height while tmp > 0: print("*",end="") tmp -= 1 print() height -= 1
测试结果: