Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help with editing this code to better apply deep-copying. I am also wondering if this code needs 2 for loops to reflect two-dimensional lists:
Please help with editing this code to better apply "deep-copying." I am also wondering if this code needs 2 for loops to reflect two-dimensional lists:
def join_map_side(map1, map2):
final_list = []
map3 = map1[:]
map4 = map2[:]
#check if both maps are same height
if len(map1) != len(map2):
return None
#starts loop to evaluate numbers in both maps
#and appends numbers of the same indices
for i in range(0, len(map1)):
final_list.append(map3[i] + map4[i])
#print(final_list)
return final_list
2 Problem: 3 def join_map_side (mapl, map2): Given two maps, create and return a new map by deep-copying mapl 4 and map2 side by side for a longer map of the same height. If their heights don't match, return None. 5 example of deep-copying: 6 |xs= [1,2,3] 7 ys-xs[:] Assume: mapl and map2 are maps as defined above. Remember, you must not modify the original maps. 10 -join-rap-side ( [ [1,2], [5, 6] ] , [ [3,4], [7, 8] ] ) [ [1, 2, 3, 4] , [5, 6, 7, 8] ] 11join_map_side ([[1, [2, [3],[4]],51, [6, [7], [[[1,51, [2,6], [3,7,[4,8] 13 L,i 12join_map_side (ml, m2)None 14 15 def join map_side (map1, map2): 16 17 18 19 20 final list- [] map3 mapl[:] map4 map2 [ : ] #check if both maps are same height if len (map1) !- len (map2) return None #starts loop to evaluate numbers in both maps and appends numbers of the same indices for i in range (0, len (map1)): 23 24 25 26 27 28 29 30 final list.append (map3[imap4 [i]) #print (finallist) return final list
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started