Michael的Python笔记(一)
来源:互联网 发布:巨牌一搜网络一搜同志 编辑:程序博客网 时间:2024/06/08 08:12
Custom Print
Now we can see the contents of our list, but clearly it would be easier to play the game if we could print the board out like a grid with each row on its own line.
We can use the fact that our board is a list of lists to help us do this. Let’s set up a for loop to go through each of the elements in the outer list (each of which is a row of our board) and print them.
说明
First, delete your existing print statement.Then, define a function named print_board with a single argument, board.Inside the function, write a for loop to iterates through each row in board and print it to the screen.Call your function with board to make sure it works.
编写源码:
思路
构建函数,利用for做循环
board = []
for i in range(1,6):n = [“O”]
board.append(n*5)def print_board(board):
for row in board:
print rowprint board
0 0
- Michael的Python笔记(一)
- Michael的Python笔记(二)
- michael的Python笔记(三)
- python的笔记(一)
- 我的Python学习笔记(一)
- python笔记(一)
- python笔记(一)
- 独家 | Michael I.Jordan:大数据时代下的安全实时决策堆栈与增强学习(视频+精华笔记)
- Michael Wand 的个人主页
- python学习笔记(一) python的安装和配置
- Python学习笔记(一)python的安装和配置
- python学习笔记(一):python的特点
- 北欧的Michael Learns To Rock的一首清澈见底的【Take Me To Your Heart】
- 北欧的Michael Learns To Rock的一首清澈见底的【Take Me To Your Heart】
- 初学Python笔记(一)
- python学习笔记(一)
- Python学习笔记(一)
- python学习笔记(一)
- AsyncTask 异步加载网络图片简单应用
- HTTPS的误解(二)
- ctf练习---ASCII码而已
- 在没SQL Server数据库情况下怎么打开.MDF文件?
- 阅读图书翻页
- Michael的Python笔记(一)
- EditText中英文混输限制长度
- Smobiler如何开启日志功能
- 聚集索引和非聚集索引(整理)
- javascript中的string与其他语言string的一些不同
- poj 1068
- Android设置透明、半透明等效果
- 编写高效的 C 和 C 代码优化
- Windows下设置MySql数据库名、表名是否区分大小写