unable to add ia single element into a 2d python list -


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

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -