Expecting below output [[0,0,0,0,0][0,0,0,0,0][0,0,0,0][0,0,0,0,0]]
But getting error "IndexError: list index out of range". Whats wrong in this code
Code :
r = 4 c = 5 list = [] temp_list =[] for r in range(r): for c in range(c): temp_list.append(0) list[c] += temp_list print(list)
===========================
https://stackoverflow.com/questions/65527204/want-to-print-multi-dimensional-list-with-all-0-elements-using-for-loop January 01, 2021 at 12:00PM
没有评论:
发表评论