提交 4275c90f 编写于 作者: 秦英杰

fix:列表

上级 5bf3e132
此差异已折叠。
# 定义行数和列数
rows = 3
cols = 3
# 使用列表推导式生成二维数组
matrix = [[(i * cols) + j + 1 for j in range(cols)] for i in range(rows)]
# 打印生成的二维数组,每个子数组后添加换行符
for row in matrix:
print(row)
\ No newline at end of file
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
new_list = []
i = 0
......@@ -8,5 +7,3 @@ while i < len(my_list):
i += 1
print(f"偶数形成的新列表:{new_list}")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册