unable to add ia single element into a 2d python list -
this question has answer here:
hi i'm afraid basic question can't work - trying change single entry in 2d array adding 3 - driving me nutty - please tell me doing wrong (see following)
list1 = [["0"]*5]*3 print (list1) list1[0][0] = "r" print (list1)
this giving me output follows "r" repeated in positon 0 3 times
[['r', '0', '0', '0', '0'], ['r', '0', '0', '0', '0'], ['r', '0', '0', '0', '0']]
Comments
Post a Comment