[Tutor] 2d list matrix 7 x 75 problem
Dave S
pythontut at pusspaws.net
Sun Mar 6 10:49:43 CET 2005
Hello,
I need to generate a list 2d matrix of the kind ...
[['', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''], ['',
'', '', '', ''], ['', '', '', '', '']]
except its dimensions need to be 7 x 75. I thought I had it sorted with
map2 = [ [''] *7 ] *75
until the coding screwed up & I realised I had 75 references to the same
list :-(
so I thought I would be clever with ...
>>> a=[0]*5
>>> a
[0, 0, 0, 0, 0]
>>> b=[a[:]]*5
same problem.
It seems realy simple but how do I generate a 7 x 75 list matrix ?
Dave
Oh PS
Is there a more elegant solution to
if string == 'sun' or string == 'mon' or string == 'tue' or string ==
'wed' or string == 'thu' or string == 'fri' or string == 'sat':
the above works but any suggestions would be welcome :-)
More information about the Tutor
mailing list