Помогите отладить код на питоне так, чтобы выводило двумерный массив типа :

[[1, 2, 3], [4, 5, 6], [7, 8, 9]]

вместо двумерного массива типа:

[[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9]]

Вот код:

n = int(input())

a = []

b = ""

c = 1

for i in range(n):

for j in range(n):

b += str(c)

c += 1

a.append([int(x) for x in b])

print(a)
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.