[Tutor] Creating a two dimension set

Phil phillor9 at gmail.com
Mon Nov 1 03:18:33 EDT 2021


On 1/11/21 06:08, Cameron Simpson wrote:

Problem solved. Actually, the solution had nothing to do with my 
question. Too much looking and not enough seeing. The following works:

num_rows = 2
num_cols = 2

grid = [[str] * num_cols for _ in range(num_rows)] # I changed None to 
str but I don't thing it matters.

for row in range(2):
     for col in range(2):
         grid[row][col] = set({'1', '2', '3', '4', '5', '6', '7', '8', '9'})

grid[0][0].remove('3')

print(grid[0][0])


I'm open to any improvements.

-- 

Regards,
Phil



More information about the Tutor mailing list