练习循环语句,和方法调用
#!/usr/bin/env python
# coding=utf-8
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def forwardTriangle():
for i in range(0, row):
for k in range(0, i + 1):
print ("*"),
print("\n")
def reversedTriangle():
for i in range(0, row):
for k in range(0, row - i):
print ("*"),
print("\n")
if __name__ == '__main__':
row = input("请输入一个数字:")
forwardTriangle()
print ("--------")
reversedTriangle()
网友评论