class Solution(object): def hb(self,list1,list2): result = [] while list1 and list2: if list1[0] < list2[0]: result.append(list1[0]) del list1[0] else: result.append(list2[0]) del list2[0] if list1: result.extend(list1) if list2: result.extend(list2) print(result) return result def findMedianSortedArrays(self, nums1, nums2): list3=self.hb(nums1, nums2) lenth=len(list3) if(lenth%2==0): ind=lenth//2 return (list3[ind]+list3[ind-1])/2.0 else: ind=lenth//2 return list3[ind]