Python程序-打印单词的菱形字符图案
2016-06-16 19:09
1071 查看
源程序如下:
a = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]
b = [' ' * 2 * (7 - i) + 'Good' * i for i in a]
for line in b:
print(line)
程序运行结果如下:
Good
GoodGood
GoodGoodGood
GoodGoodGoodGood
GoodGoodGoodGoodGood
GoodGoodGoodGoodGoodGood
GoodGoodGoodGoodGoodGoodGood
GoodGoodGoodGoodGoodGood
GoodGoodGoodGoodGood
GoodGoodGoodGood
GoodGoodGood
GoodGood
Good
a = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]
b = [' ' * 2 * (7 - i) + 'Good' * i for i in a]
for line in b:
print(line)
程序运行结果如下:
Good
GoodGood
GoodGoodGood
GoodGoodGoodGood
GoodGoodGoodGoodGood
GoodGoodGoodGoodGoodGood
GoodGoodGoodGoodGoodGoodGood
GoodGoodGoodGoodGoodGood
GoodGoodGoodGoodGood
GoodGoodGoodGood
GoodGoodGood
GoodGood
Good
相关文章推荐
- pip2 与 pip3
- python WEB UI自动化在日期框中动态输入当前日期
- python实现东南大学体育馆自动预约
- python之web业务质量检测
- 从局部变量和全局变量开始全面解析Python中变量的作用域
- Python, 数据抓取
- BuildBinaryTreeby前序遍历和中序遍历 python java leetcode
- Python的安装和环境配置
- 实例讲解Python中global语句下全局变量的值的修改
- 将Mercurial整合到Flask项目中
- 用Python+Django在Eclipse环境下开发web网站【转】
- 最大K个数问题的Python版解法总结
- DepthBinaryTree leetcode java python
- 初心大陆-----python宝典 第二章
- Python基本知识点
- python练习1-猜数游戏
- 290. Word Pattern [easy] (Python)
- python格式化输出 学习学习
- [leetcode]40. Combination Sum II ,python实现【medium难度】
- Python中的yield是如何使用的