CP104 Study Guide - Final Guide: Butterscotch
Final Exam practice
Question 1(zero_init)
def zero_init(wholelist):
for i in range (len(wholelist)):
for c in range(len(wholelist[0])):
wholelist[i].pop(c)
wholelist[i].insert(c,0)
return wholelist
#main program
rows=int(input('enter the number of rows'))
cols=int(input('enter the number of columns'))
wholelist=[ ]
for i in range (rows):
sublist=[ ]
for c in range (cols):
items=input('enter an element')
sublist.append(items)
wholelist.append(sublist)
print(wholelist)
hayjayshay and 38575 others unlocked
2
CP104 Full Course Notes
Verified Note
2 documents