Python function to add integers to list advice much appreciated

  python, python-3.x

It is a function that accepts a list of integers sorted in increasing order and another integer to insert into that list.

This is what I have so far:

def insert_sorted():
    user_array = 0
    array = input("Please insert a list")
    user_array = input("Please insert an integer to add to the list")
    return list.insert()

This is the output I’m looking for:

 >>> array = [1, 4, 5, 9, 13, 15]
 >>> insert_sorted(array, 6)
 >>> array
 [1, 4, 5, 6, 9, 13, 15]

Source: Python-3x Questions

LEAVE A COMMENT