I have a 4x4 matrix B. I want to substitue the entire first line for a specific value (2):
B[0]=2.0
If I put this way the first line becomes [2,[....],[....],[....]]
and not [[2,2,2,2],[....],[....],[....]]
.
How can I fix that?
You can do B[0] = [2 for x in range(4)]
you could also do B[0] = [2,2,2,2]
but if the size changes then you can put B[0] = [2 for x in range(size)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.