id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav1780@gmail.com 04_lists > merge
prev  |  next  |  chance

Define a function that when passed two lists, each sorted in ascending order, returns a list that merges the two lists in an overall ascending order. Treat a null list as an empty list. Note: Python uses "None" instead of "null" merge([10, 70, 90], [20]) → [10, 20, 70, 90] merge([], [1, 2, 3, 4, 5, 6]) → [1, 2, 3, 4, 5, 6] merge([1, 2, 3, 4, 5, 6, 7, 8], []) → [1, 2, 3, 4, 5, 6, 7, 8]


merge([10, 70, 90], [20]) → [10, 20, 70, 90]
merge([], [1, 2, 3, 4, 5, 6]) → [1, 2, 3, 4, 5, 6]
merge([1, 2, 3, 4, 5, 6, 7, 8], []) → [1, 2, 3, 4, 5, 6, 7, 8]

...Save, Compile, Run (ctrl-enter)

def merge(list1, list2):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 4 Post-solution available

Copyright Nick Parlante 2017 - privacy