|
|
发表于 2022-3-26 18:44:12
|
显示全部楼层
代码正确很好,只是还差 show_row 和 roll_and_show 函数:
- import random
- def show_roll(num):
- image = [
- [
- "*****",
- "* *",
- "* O *",
- "* *",
- "*****"
- ],
- [
- "*****",
- "* O*",
- "* *",
- "*O *",
- "*****"
- ],
- [
- "*****",
- "* O*",
- "* O *",
- "*O *",
- "*****"
- ],
- [
- "*****",
- "*O O*",
- "* *",
- "*O O*",
- "*****"
- ],
- [
- "*****",
- "*O O*",
- "* O *",
- "*O O*",
- "*****"
- ],
- [
- "*****",
- "*O O*",
- "*O O*",
- "*O O*",
- "*****"
- ]
- ]
- for n in image[num - 1]:
- print(n)
- print()
- def throw_dice():
- return random.randint(1,6)
- def roll_and_show():
- show_roll(throw_dice())
- for i in range(3):
- roll_and_show()
复制代码 |
|