CS 61A

Structure and Interpretation of Computer Programs, Spring 2015

Instructor: John DeNero




Question | Over Nine Thousand

Define over_nine_thousand, which takes a list o_list, and modifies that list by adding 9000 to each element.

def over_nine_thousand(o_list):
    """
    >>> original_list = [1, 2, 3, 4, 5]
    >>> over_nine_thousand(original_list)
    >>> original_list
    [9001, 9002, 9003, 9004, 9005]
    """
    ## YOUR CODE HERE ##
def over_nine_thousand(original_list):
    index = 0
    while index < len(original_list):
        original_list[index] += 9000
        index += 1